#include <bits/stdc++.h>
using namespace std;
int n, a, b;
string s, x, x1;
int main() {
cin >> n;
if (n==2) {
cin >> a >> b;
cout << b << " " << a << endl;
return 0;
} else
for (int i = 1; i <= n; i++) {
    cin >> s;
    x+=s;
}
x1 = x;
for (int i = 0; i < n; i++) {
    for (int j = n-1; j >= 0; j--) {
        if (x[i] < x[j]) {
            swap(x[i], x[j]);
            break;
        }
        break;
    }
    break;
}

if (x == x1) {
for (int i = 0; i < n; i++) {
    for (int j = 1; j <= n; j++) {
        if (x[i] < x[j]) {
            swap(x[i], x[j]);
            break;
        }
        break;
    }
    break;
}
}
for (int i = 0; i < x.size(); i++) {
    cout << x[i] << " ";
}

return 0;
}