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