#include <iostream>
#include <fstream>
#include <cstdlib>
#include <time.h>
using namespace std;
#define maxn 500010
int n, a[maxn];
void qsort(int st, int dr)
{
if (st>=dr) return;
if (st+1==dr) {if (a[st]>a[dr]) swap(a[st], a[dr]); return;}
int ind, i, j, m;
ind=st + 1 + rand() %(dr-st);
m=a[ind];
i=st; j=dr;
while(i<=j)
{
while (a[i]<m && i<=n) i++;
while (a[j]>m && j>=1) j--;
if (i<=j) {swap(a[i], a[j]); i++; j--;}
}
qsort(st, j);
qsort(j+1, dr);
}
int main()
{
ifstream f("algsort.in");
ofstream g("algsort.out");
srand(time(NULL));
f>>n;
int i;
for (i=1;i<=n;i++) f>>a[i];
qsort(1, n);
for (i=1;i<=n;i++) g<<a[i]<< ' ';
g<<'\n';
}