#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<int> A, B;
  A.resize(N);
  B.resize(N);
  int max = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    if (B[i] == A[N - 1]) {
      cout << A[N - 1] << endl;
    } else {
      cout << A[N - 2] << endl;
    }
  }
  return 0;
}
