#include<iostream>
#include<algorithm>
using namespace std;
int n;
int a[200005],b[200005];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a,a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(b[i]==a[n]) cout<<a[n-1]<<endl;
		else cout<<a[n]<<endl;
	}
	return 0;
}