#include <bits/stdc++.h>
using namespace std;
#define N 200005
int a[N],b[N];
int main() {
	int n,mx = 0;
	cin >> n;
	for(int i=1; i<=n; i++) {
		scanf("%d",&a[i]),b[i] = a[i];
	}
	sort(b+1,b+n+1);
	for(int i=1; i<=n; i++) {
		if(a[i] == b[n]) printf("%d\n",b[n-1]);
		else printf("%d\n",b[n]);
	}

	return 0;
}