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