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