#include <iostream>
using namespace std;
void merge(int arr[], int left, int mid, int right) {
int n1 = mid - left + 1;
int n2 = right - mid;
int *L = new int[n1];
int *R = new int[n2];
for (int i = 0; i < n1; i++) L[i] = arr[left + i];
for (int j = 0; j < n2; j++) R[j] = arr[mid + 1 + j];
int i = 0, j = 0, k = left;
while (i < n1 && j < n2) {
if (L[i] <= R[j]) {
arr[k++] = L[i++];
} else {
arr[k++] = R[j++];
}
}
while (i < n1) arr[k++] = L[i++];
while (j < n2) arr[k++] = R[j++];
delete[] L;
delete[] R;
}
void mergeSort(int arr[], int left, int right) {
if (left < right) {
int mid = left + (right - left) / 2;
mergeSort(arr, left, mid);
mergeSort(arr, mid + 1, right);
merge(arr, left, mid, right);
}
}
int main() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) cin >> arr[i];
mergeSort(arr, 0, n - 1);
for (int i = 0; i < n; i++) cout << arr[i] << " ";
cout << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCBtZXJnZShpbnQgYXJyW10sIGludCBsZWZ0LCBpbnQgbWlkLCBpbnQgcmlnaHQpIHsKICAgIGludCBuMSA9IG1pZCAtIGxlZnQgKyAxOwogICAgaW50IG4yID0gcmlnaHQgLSBtaWQ7CiAgICAKICAgIGludCAqTCA9IG5ldyBpbnRbbjFdOwogICAgaW50ICpSID0gbmV3IGludFtuMl07CiAgICAKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjE7IGkrKykgTFtpXSA9IGFycltsZWZ0ICsgaV07CiAgICBmb3IgKGludCBqID0gMDsgaiA8IG4yOyBqKyspIFJbal0gPSBhcnJbbWlkICsgMSArIGpdOwogICAgCiAgICBpbnQgaSA9IDAsIGogPSAwLCBrID0gbGVmdDsKICAgIAogICAgd2hpbGUgKGkgPCBuMSAmJiBqIDwgbjIpIHsKICAgICAgICBpZiAoTFtpXSA8PSBSW2pdKSB7CiAgICAgICAgICAgIGFycltrKytdID0gTFtpKytdOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGFycltrKytdID0gUltqKytdOwogICAgICAgIH0KICAgIH0KICAgIAogICAgd2hpbGUgKGkgPCBuMSkgYXJyW2srK10gPSBMW2krK107CiAgICB3aGlsZSAoaiA8IG4yKSBhcnJbaysrXSA9IFJbaisrXTsKICAgIAogICAgZGVsZXRlW10gTDsKICAgIGRlbGV0ZVtdIFI7Cn0KCnZvaWQgbWVyZ2VTb3J0KGludCBhcnJbXSwgaW50IGxlZnQsIGludCByaWdodCkgewogICAgaWYgKGxlZnQgPCByaWdodCkgewogICAgICAgIGludCBtaWQgPSBsZWZ0ICsgKHJpZ2h0IC0gbGVmdCkgLyAyOwogICAgICAgIAogICAgICAgIG1lcmdlU29ydChhcnIsIGxlZnQsIG1pZCk7CiAgICAgICAgbWVyZ2VTb3J0KGFyciwgbWlkICsgMSwgcmlnaHQpOwogICAgICAgIAogICAgICAgIG1lcmdlKGFyciwgbGVmdCwgbWlkLCByaWdodCk7CiAgICB9Cn0KCmludCBtYWluKCkgewogICAgaW50IG47CiAgICBjaW4gPj4gbjsKICAgIGludCBhcnJbbl07CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgY2luID4+IGFycltpXTsKICAgIAogICAgbWVyZ2VTb3J0KGFyciwgMCwgbiAtIDEpOwogICAgCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgY291dCA8PCBhcnJbaV0gPDwgIiAiOwogICAgY291dCA8PCBlbmRsOwogICAgcmV0dXJuIDA7Cn0=