#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int>> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  for (long long int i = n - 1; i >= 0; i--) {
    long long int index = n - 1;
    while (index > 0) {
      if (a[index].second != i) {
        break;
      }
      index--;
    }
    cout << a[index].first << endl;
  }
}
