#include <iostream>
using namespace std;
const int MAX_LENGTH = 1000;
const int HUNDRED = 100;
int main() {
int n, v[MAX_LENGTH + 1];
cin >> n;
for (int i = 0; i < n; ++i) { // Citirea numerelor
cin >> v[i];
}
for (int i = 0; i < n - 1; ++i) { // Sortarea numerelor după ultimele două cifre
for (int j = i + 1; j < n; ++j) {
int lastTwoDigitsI = v[i] % HUNDRED;
int lastTwoDigitsJ = v[j] % HUNDRED;
if (lastTwoDigitsI > lastTwoDigitsJ || (lastTwoDigitsI == lastTwoDigitsJ && v[i] > v[j])) { // Comparare după ultimele două cifre
int aux = v[i]; // Schimbă valorile dacă sunt în ordine greșită
v[i] = v[j];
v[j] = aux;
}
}
}
for (int i = 0; i < n; ++i) { // Afișarea numerelor sortate
cout << v[i] << " ";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9MRU5HVEggPSAxMDAwOwpjb25zdCBpbnQgSFVORFJFRCA9IDEwMDsKCmludCBtYWluKCkgewogICAgaW50IG4sIHZbTUFYX0xFTkdUSCArIDFdOwogICAgY2luID4+IG47CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkgeyAvLyBDaXRpcmVhIG51bWVyZWxvcgogICAgICAgIGNpbiA+PiB2W2ldOwogICAgfQogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuIC0gMTsgKytpKSB7IC8vIFNvcnRhcmVhIG51bWVyZWxvciBkdXDEgyB1bHRpbWVsZSBkb3XEgyBjaWZyZQogICAgICAgIGZvciAoaW50IGogPSBpICsgMTsgaiA8IG47ICsraikgewogICAgICAgICAgICBpbnQgbGFzdFR3b0RpZ2l0c0kgPSB2W2ldICUgSFVORFJFRDsKICAgICAgICAgICAgaW50IGxhc3RUd29EaWdpdHNKID0gdltqXSAlIEhVTkRSRUQ7CiAgICAgICAgICAgIGlmIChsYXN0VHdvRGlnaXRzSSA+IGxhc3RUd29EaWdpdHNKIHx8IChsYXN0VHdvRGlnaXRzSSA9PSBsYXN0VHdvRGlnaXRzSiAmJiB2W2ldID4gdltqXSkpIHsgLy8gQ29tcGFyYXJlIGR1cMSDIHVsdGltZWxlIGRvdcSDIGNpZnJlICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgaW50IGF1eCA9IHZbaV07IC8vIFNjaGltYsSDIHZhbG9yaWxlIGRhY8SDIHN1bnQgw65uIG9yZGluZSBncmXImWl0xIMKICAgICAgICAgICAgICAgIHZbaV0gPSB2W2pdOwogICAgICAgICAgICAgICAgdltqXSA9IGF1eDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKSB7IC8vIEFmaciZYXJlYSBudW1lcmVsb3Igc29ydGF0ZQogICAgICAgIGNvdXQgPDwgdltpXSA8PCAiICI7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==