#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) {
if (v[i] % HUNDRED > v[j] % HUNDRED ||
(v[i] % HUNDRED == v[j] % HUNDRED && 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+PiB2W2ldOwogICAgfQogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuIC0gMTsgKytpKSB7IC8vIFNvcnRhcmVhIG51bWVyZWxvciBkdXDEgyB1bHRpbWVsZSBkb3XEgyBjaWZyZQogICAgICAgIGZvciAoaW50IGogPSBpICsgMTsgaiA8IG47ICsraikgewogICAgICAgICAgICBpZiAodltpXSAlIEhVTkRSRUQgPiB2W2pdICUgSFVORFJFRCB8fCAKICAgICAgICAgICAgKHZbaV0gJSBIVU5EUkVEID09IHZbal0gJSBIVU5EUkVEICYmIHZbaV0gPiB2W2pdKSkgeyAvLyBDb21wYXJhcmUgZHVwxIMgdWx0aW1lbGUgZG91xIMgY2lmcmUgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICBpbnQgYXV4ID0gdltpXTsgLy8gU2NoaW1ixIMgdmFsb3JpbGUgZGFjxIMgc3VudCDDrm4gb3JkaW5lIGdyZciZaXTEgwogICAgICAgICAgICAgICAgdltpXSA9IHZbal07CiAgICAgICAgICAgICAgICB2W2pdID0gYXV4OwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsgLy8gQWZpyJlhcmVhIG51bWVyZWxvciBzb3J0YXRlCiAgICAgICAgY291dCA8PCB2W2ldIDw8ICIgIjsKICAgIH0KICAgIHJldHVybiAwOwp9