#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-Ofast")
using namespace std;
const long long MAX = 2e5 + 5;
const long long MAAX = 1e9;
const long long MOD = 1e9 + 7;
long long n, a[MAX], inp[MAX];
long long main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    inp[i] = a[i];
  }
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    cout << a[n - 1 - (inp[i] == a[n - 1])] << endl;
  }
  return 0;
}
