#include <iostream>
using namespace std;
int sum(int x){
int s=0,i;
for(i=2;i*i<x;i++){
if(x%i==0) s+= i + x/i;
}
if(i*i==x && x%i==0) s+= i;
return s;
}
int main(){
int n,i,v[i];
cin >> n;
for(i=1;i<=n;i++){
cin >> v[i];
v[i] = sum(v[i]);
}
//Bubble sort
int ok=1;
while(ok){
ok=0;
for(i=1;i<n;i++)
if(v[i]>v[i+1]){
swap(v[i],v[i+1]);
ok=1;
}
}
for(i=1;i<=n;i++) cout << v[i] << " ";
}