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