#include <iostream>
using namespace std;
void quickSort(int arr[], int low, int high) {
if (low < high) {
int pivot = arr[high];
int i = low - 1;
for (int j = low; j < high; j++) {
if (arr[j] < pivot) {
i++;
// Swap arr[i] and arr[j]
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
// Swap arr[i+1] and arr[high] (pivot)
// This is where the pivot is placed in its correct sorted position
int pi = i + 1;
int temp = arr[pi];
arr[pi] = arr[high];
arr[high] = temp;
quickSort(arr, low, pi - 1);
quickSort(arr, pi + 1, high);
}
}
int main() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
quickSort(arr, 0, n - 1);
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCBxdWlja1NvcnQoaW50IGFycltdLCBpbnQgbG93LCBpbnQgaGlnaCkgewogICAgaWYgKGxvdyA8IGhpZ2gpIHsKICAgICAgICBpbnQgcGl2b3QgPSBhcnJbaGlnaF07CiAgICAgICAgaW50IGkgPSBsb3cgLSAxOwoKICAgICAgICBmb3IgKGludCBqID0gbG93OyBqIDwgaGlnaDsgaisrKSB7CiAgICAgICAgICAgIGlmIChhcnJbal0gPCBwaXZvdCkgewogICAgICAgICAgICAgICAgaSsrOwogICAgICAgICAgICAgICAgLy8gU3dhcCBhcnJbaV0gYW5kIGFycltqXQogICAgICAgICAgICAgICAgaW50IHRlbXAgPSBhcnJbaV07CiAgICAgICAgICAgICAgICBhcnJbaV0gPSBhcnJbal07CiAgICAgICAgICAgICAgICBhcnJbal0gPSB0ZW1wOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIAogICAgICAgIC8vIFN3YXAgYXJyW2krMV0gYW5kIGFycltoaWdoXSAocGl2b3QpCiAgICAgICAgLy8gVGhpcyBpcyB3aGVyZSB0aGUgcGl2b3QgaXMgcGxhY2VkIGluIGl0cyBjb3JyZWN0IHNvcnRlZCBwb3NpdGlvbgogICAgICAgIGludCBwaSA9IGkgKyAxOwogICAgICAgIGludCB0ZW1wID0gYXJyW3BpXTsKICAgICAgICBhcnJbcGldID0gYXJyW2hpZ2hdOwogICAgICAgIGFycltoaWdoXSA9IHRlbXA7CgogICAgICAgIHF1aWNrU29ydChhcnIsIGxvdywgcGkgLSAxKTsKICAgICAgICBxdWlja1NvcnQoYXJyLCBwaSArIDEsIGhpZ2gpOwogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIGludCBuOwogICAgY2luID4+IG47CiAgICBpbnQgYXJyW25dOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBjaW4gPj4gYXJyW2ldOwogICAgfQogICAgcXVpY2tTb3J0KGFyciwgMCwgbiAtIDEpOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBjb3V0IDw8IGFycltpXSA8PCAiICI7CiAgICB9CiAgICBjb3V0IDw8IGVuZGw7CiAgICByZXR1cm4gMDsKfQ==