#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const vector<ll> dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A[i];
  }
  vector<ll> ans;
  for (ll count = 0; count < N; ++count) {
    for (ll i = 0; i < N; ++i) {
      if (i == count) {
        continue;
      }
      ans.emplace_back(A[i]);
    }
    sort(ans.rbegin(), ans.rend());
    cout << ans[0] << endl;
    ans.resize(0);
  }
}
