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