#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	ll n;
	cin>>n;
	ll p[n],a[n];
	for(int i=0;i<n;i++){
	    cin>>p[i];
	    a[i]=p[i];
	}
	sort(p,p+n);
	for(int i=0;i<n;i++){
	    if(a[i]==p[n-1])cout<<p[n-2]<<endl;
	    else cout<<p[n-1]<<endl;
	}
	return 0;
}