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