#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[200005],ar2[200005],n;
int32_t main(){
	cin>>n;for(int i=1;i<=n;i++){cin>>ar[i];ar2[i]=ar[i];}
	sort(ar2+1,ar2+n+1);
	for(int i=1;i<=n;i++){
		cout<<ar2[n-(ar[i]==ar2[n])]<<"\n";
	}
}
