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