#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
int a[200010],b[200010];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%d",a+i),b[i]=a[i];
	sort(a+1,a+1+n);
	
	for(int i=1;i<=n;i++){
		if(b[i]==a[n])printf("%d\n",a[n-1]);else printf("%d\n",a[n]);
	}
}