#include <bits/stdc++.h>
using namespace std;
long long n, c;
long long a[200005];
long long b[200005];
long long const BAD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> c;
    a[i] = c;
    b[i] = c;
  }
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    if (b[i] == a[n]) {
      cout << a[n - 1] << '\n';
    } else {
      cout << a[n] << '\n';
    }
  }
}
