#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  ll n;
  cin >> n;
  vector<ll> v;
  while (n--) {
    ll no;
    cin >> no;
    v.push_back(no);
  }
  for (ll i = 0; i < v.size(); i++) {
    ll temp = v[i];
    v[i] = 0;
    cout << *max_element(v.begin(), v.end()) << endl;
    v[i] = temp;
  }
  return 0;
}
