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