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