#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, ans = 0;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++) {
    M = 0;
    for (int j = 0; j < N; j++) {
      if (i == j)
        continue;
      else
        M = max(a[j], M);
    }
    cout << M << endl;
  }
}
