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