#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
  int n;
  cin >> n;
  int *a = new int[n];
  int *b = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  bool same = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] != a[0]) same = 0;
  }
  if (same == 1) {
    for (int i = 0; i < n; i++) cout << a[i] << endl;
  } else {
    sort(b, b + n, cmp);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (a[i] != b[j]) {
          cout << b[j] << endl;
          break;
        }
      }
    }
  }
  delete[] a;
  return 0;
}
