#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int* A = new int[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int* B = new int[N];
  memcpy(B, A, sizeof(int) * N);
  sort(B, B + N);
  for (int i = 0; i < N; i++) {
    if (B[N - 1] == A[i])
      cout << B[N - 2] << endl;
    else
      cout << B[N - 1] << endl;
  }
  return 0;
}
