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