#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N), maxA(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  maxA = A;
  sort(maxA.begin(), maxA.end());
  reverse(maxA.begin(), maxA.end());
  for (int i = 0; i < N; i++) {
    int maxNum = 0;
    if (maxA.at(0) > A.at(i)) {
      maxNum = maxA.at(0);
    } else {
      maxNum = maxA.at(1);
    }
    cout << maxNum << endl;
  }
}
