#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  int a[2000000];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    int sw = a[i];
    a[i] = -1;
    int max = *max_element(a, a + N);
    cout << max << endl;
    a[i] = sw;
  }
  return 0;
}
