#include <bits/stdc++.h>
using namespace std;
long long pow_mod(long long x, long long y, long long MOD) {
  long long ret = 1;
  while (y) {
    if (y & 1) ret = ret * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return ret;
}
signed main() {
  long long N;
  cin >> N;
  long long A[N];
  for (long long i = 0; i < (long long)(N); i++) cin >> A[i];
  long long max_tmp = 0;
  for (long long i = 0; i < (long long)(N); i++) {
    if (max_tmp < A[i]) {
      max_tmp = A[i];
    }
  }
  long long max_true = 0;
  for (long long i = 0; i < (long long)(N); i++) {
    max_true = 0;
    if (max_tmp == A[i]) {
      for (long long j = 0; j < (long long)(N); j++) {
        if (i == j) continue;
        if (max_true < A[j]) {
          max_true = A[j];
        }
      }
      cout << max_true << endl;
    } else {
      cout << max_tmp << endl;
    }
  }
  return 0;
}
