#include <bits/stdc++.h>
using namespace std;
int partition (int *ARR, int start, int end){
int pivot = ARR[end];
int i = (start - 1);
for (int j = start; j <= end - 1; j++){
if (ARR[j] < pivot){
i++;
swap(ARR[i],ARR[j]);
}
}
swap(ARR[i+1],ARR[end]);
return (i + 1);
}
void quick(int *ARR, int start, int end){
if (start < end){
int p = partition(ARR, start, end);
quick(ARR, start, p - 1);
quick(ARR, p + 1, end);
}
}
int main(){
int N;
cin>>N;
int ARR[N];
for (int i = 0; i < N; i++)
cin>>ARR[i];
quick(ARR, 0, N - 1);
for (int i = 0; i < N; i++)
cout<<ARR[i]<<' ';
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgcGFydGl0aW9uIChpbnQgKkFSUiwgaW50IHN0YXJ0LCBpbnQgZW5kKXsgIAogICAgaW50IHBpdm90ID0gQVJSW2VuZF07CiAgICBpbnQgaSA9IChzdGFydCAtIDEpOyAgCiAgICBmb3IgKGludCBqID0gc3RhcnQ7IGogPD0gZW5kIC0gMTsgaisrKXsgIAogICAgICAgIGlmIChBUlJbal0gPCBwaXZvdCl7ICAKICAgICAgICAgICAgaSsrOyAKICAgICAgICAgICAgc3dhcChBUlJbaV0sQVJSW2pdKTsKICAgICAgICB9ICAKICAgIH0gIAogICAgc3dhcChBUlJbaSsxXSxBUlJbZW5kXSk7CiAgICByZXR1cm4gKGkgKyAxKTsgIAp9Cgp2b2lkIHF1aWNrKGludCAqQVJSLCBpbnQgc3RhcnQsIGludCBlbmQpeyAgCiAgICBpZiAoc3RhcnQgPCBlbmQpeyAgCiAgICAgICAgaW50IHAgPSBwYXJ0aXRpb24oQVJSLCBzdGFydCwgZW5kKTsKICAgICAgICBxdWljayhBUlIsIHN0YXJ0LCBwIC0gMSk7ICAKICAgICAgICBxdWljayhBUlIsIHAgKyAxLCBlbmQpOyAgCiAgICB9ICAKfSAgCgppbnQgbWFpbigpeyAgCiAgICBpbnQgTjsKICAgIGNpbj4+TjsKICAgIGludCBBUlJbTl07ICAKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgTjsgaSsrKSAgCiAgICAgICAgY2luPj5BUlJbaV07CiAgICAgICAgCiAgICBxdWljayhBUlIsIDAsIE4gLSAxKTsKICAgIAogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBOOyBpKyspICAKICAgICAgICBjb3V0PDxBUlJbaV08PCcgJzsgIAogICAgICAKICAgIHJldHVybiAwOyAgCn0g