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