#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>v(n);
	for(auto& p:v){
		cin>>p;
	}
	vector<int>b=v;
	sort(b.rbegin(),b.rend());
	for(int i=0;i<n;i++){
		if(v[i]==b[0])cout<<b[1]<<endl;
		else cout<<b[0]<<endl;
	}
	return 0;
}