#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A[200000];
  cin >> N;
  vector<int> AA(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    AA[i] = A[i];
  }
  sort(AA.begin(), AA.end());
  for (int i = 0; i < N; i++) {
    for (int j = N; j > 0; j--) {
      if (A[i] != AA[j]) {
        cout << AA[j] << endl;
        break;
      }
    }
  }
}
