#include <iostream>
#include<vector>
#include<algorithm>
#include <stdlib.h>
using namespace std;
long long int a[200010], b, c, temp;
long long int back, front;
void swap( long long int& a, long long int& b) {
long long int c;
c = a;
a = b;
b = c;
}
void q( long long int left, long long int right) {
if (left >= right)
return;
temp = a[left];
front = left;
back = right;
while (back != front) {
while (a[back] >= temp&&back>front) {
back--;
}
if (front < back) {
// a[front] = a[back];
swap(a[back], a[front]);
front++;
}
while (a[front] <= temp&&front<back){
front++;
}
if (front < back) {
//a[back] = a[front];
swap(a[back], a[front]);
back--;
}
}
a[back] = temp;
if (front > left) {
q(left, front - 1);
}
if (back < right) {
q(back + 1, right);
}
}
int main()
{
scanf("%lld", &b);
for (c = 0; c < b; c++) {
scanf("%lld", &a[c]);
}
random_shuffle(a,a+b);
random_shuffle(a,a+b);
random_shuffle(a,a+b);
q(0, b - 1);
for (c = 0; c < b; c++) {
printf("%lld ", a[c]);
}
}
```cpp