#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, *a;
  cin >> n;
  a = (int*)malloc(sizeof(int) * n);
  int i;
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    if (a[i] != a[n - 1])
      cout << a[n - 1] << endl;
    else
      cout << a[n - 2] << endl;
  }
  return 0;
}
