#include<stdio.h> #include<stdlib.h> #include<iostream> #include<algorithm> #define N 1000000 using namespace std; int a[N]; void quicksort(int x[], int left, int right) { if(left >= right)return; int i = left; int j = right; swap(x[i], x[(rand() % (right - left + 1)) + left]); int key = x[i]; while(i < j){ while(i < j && x[j] >= key)j--; if(i < j)swap(x[i++], x[j]); while(i < j && x[i] <= key)i++; if(i < j)swap(x[i], x[j--]); } quicksort(x, left, i - 1); quicksort(x, i + 1, right); } int main() { int n; while(~scanf("%d", &n)){ for(int i = 0; i < n; i++){ cin >> a[i]; } quicksort(a, 0, n - 1); for(int i = 0; i < n; i++){ cout << a[i] << ' '; } cout << endl; } return 0; }