#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  int arr[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &arr[i]);
  }
  for (int i = 0; i < N; ++i) {
    int max = arr[0];
    int j = 0;
    while (j < N) {
      if (arr[j] > max && j != i) max = arr[j];
      j++;
    }
    printf("%d\n", max);
  }
  return 0;
}
