#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[200000 + 2], maxi = 0;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (j == i)
        continue;
      else {
        if (A[j] > maxi) maxi = A[j];
      }
    }
    cout << maxi << endl;
    maxi = 0;
  }
  return 0;
}
