#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, i, j, tmp, target;
  vector<int> A;
  cin >> N;
  vector<int> _A(N);
  for (i = 0; i < N; i++) {
    cin >> tmp;
    A.push_back(tmp);
  }
  copy(A.begin(), A.end(), _A.begin());
  sort(_A.begin(), _A.end());
  for (i = 0; i < N; i++) {
    target = A[i];
    for (j = N - 1; j >= 0; j--) {
      tmp = _A[j];
      if (tmp != target || j == 0) {
        cout << tmp << endl;
        break;
      }
    }
  }
  return 0;
}
