#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200000+10;
int n,a[N],sum,f[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		f[i]=a[i];
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		if(f[i]==a[n])printf("%d\n",a[n-1]);
		else printf("%d\n",a[n]);
	return 0;
}
