#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int* p = new int[N];
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < N; i++) {
    int tmp = -1;
    for (int j = 0; j < N; j++) {
      if (j != i && p[j] > tmp) {
        tmp = p[j];
      }
    }
    cout << tmp << endl;
  }
}
