#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  int A[200010]{};
  for (int i = 0; i < N; i++) cin >> A[i];
  int count = 0;
  while (count < N) {
    int max = 0;
    for (int i = 0; i < N; i++) {
      if (count == i) continue;
      if (A[i] > max) max = A[i];
    }
    count++;
    cout << max << endl;
  }
}
