#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

signed main(){
  ll n;cin>>n;
  vector<ll> v(n),u(n);

  rep(i,n){
    cin>>v[i];
  }
  u=v;
  sort(all(u),greater<ll>());

  rep(i,n) cout<<u.at(u[0]==v[i])<<endl;
  
}
