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