#include<bits/stdc++.h>
using namespace std;
#define M (200010)
#define ll long long
int n,a[M],b[M];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+1+n);
	for (int i=1;i<=n;i++) 
		if (a[i]!=b[n]) printf("%d\n",b[n]);
		else printf("%d\n",b[n-1]);	
}
