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