#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int i, j, k;
  cin >> N;
  int A[N];
  int comp;
  for (i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (j = 0; j < N; j++) {
    comp = 0;
    for (k = 0; k < N; k++) {
      if (j != k && comp < A[k]) {
        comp = A[k];
      }
    }
    cout << comp << endl;
  }
  return 0;
}
