#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
  cin >> N;
  int A[N + 1];
  for (int i = 0; i < N; ++i) cin >> A[i];
  int max_v = 0;
  for (int i = 0; i < N; i++) {
    max_v = -10000;
    for (int j = 0; j < N; j++) {
      if (j == i) continue;
      if (A[j] > max_v) max_v = A[j];
    }
    cout << max_v << endl;
  }
}
