#include <bits/stdc++.h>
using namespace std;
int main() {
  FILE *fin = NULL, *fout = NULL;
  int N;
  scanf("%d", &N);
  int A[200001], cpy[200001];
  for (int i = 0; i < N; i++) {
    scanf("%d", A + i);
  }
  sort(cpy, cpy + N);
  for (int i = 0; i < N; i++) {
    if (A[i] != cpy[N - 1]) {
      printf("%d\n", cpy[N - 1]);
    } else {
      printf("%d\n", cpy[N - 2]);
    }
  }
  if (NULL != fin) fclose(fin);
  if (NULL != fout) fclose(fout);
  return 0;
}
