#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  vector<vector<int>> A(200000, vector<int>(2));
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i][0];
    A[i][1] = i;
  }
  int tmp, tmp2;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      if (A[i][0] < A[j][0]) {
        tmp = A[i][0];
        A[i][0] = A[j][0];
        A[j][0] = tmp;
        tmp2 = A[i][1];
        A[i][1] = A[j][1];
        A[j][1] = tmp2;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A[j][1] != i) {
        cout << A[j][0] << endl;
        break;
      }
    }
  }
  return 0;
}
