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