#include <bits/stdc++.h>
int main(void) {
  int i, j, k;
  int N, A[200001];
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  for (i = 0; i < N; i++) {
    int answer = 0;
    for (j = 0; j < N; j++) {
      if (A[j] > answer && i != j) {
        answer = A[j];
      }
    }
    printf("%d\n", answer);
  }
  return 0;
}
