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