#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<long long> a(n, 0);
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  for (long long i = 0; i < (long long)(n); i++) {
    a[i] == a[0] ? cout << a[1] << endl : cout << a[0] << endl;
  }
}
