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