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