#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a, b;
  for (int i = 0; i < n; ++i) {
    int t;
    scanf("%d", &t);
    a.push_back(t);
  }
  b = a;
  sort(b.begin(), b.end());
  for (int i = 0; i < a.size(); ++i) {
    int t = 0;
    for (int j = b.size() - 1; j >= 0; --j) {
      if (b[j] == a[j] && 0 == t) {
        t++;
        continue;
      } else
        printf("%d", b[j]);
    }
  }
  return 0;
}
