#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  int maxi = -1;
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    if (vec.at(i) > maxi) maxi = vec.at(i);
  }
  for (int i = 0; i < N; i++) {
    int a = -1;
    if (vec.at(i) == maxi) {
      for (int j = 0; j < N; j++) {
        if (j == i) continue;
        if (vec.at(j) > a) a = vec.at(j);
      }
      cout << a << endl;
    } else
      cout << maxi << endl;
  }
  return 0;
}
