#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;
int main() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  ll ma = 0;
  for (int i = 0; i < (n); ++i) {
    cin >> v[i];
    ma = max(ma, v[i]);
  }
  for (ll i = 0; i < n; ++i) {
    ll res = 0;
    if (ma == v[i]) {
      for (int j = 0; j < (n); ++j) {
        if (i == j) continue;
        res = max(res, v[j]);
      }
    } else {
      res = ma;
    }
    cout << res << endl;
  }
  return 0;
}
