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