#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A[200000], sA[200000];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sA[i] = A[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (sA[i] < sA[j]) {
        int tmp = sA[i];
        sA[i] = sA[j];
        sA[j] = tmp;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    int j = 0;
    if (A[i] == sA[0])
      cout << sA[1] << endl;
    else
      cout << sA[j] << endl;
  }
  return 0;
}
