#include <bits/stdc++.h>
using namespace std;
int a[2000005];
int main() {
  long long n;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  printf("\n");
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    if (a[i] != a[n]) {
      printf("%d\n", a[n]);
    } else {
      printf("%d\n", a[n - 1]);
    }
  return 0;
}
