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