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