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