#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	int A[N], c[N];
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		c[i] = A[i];
	}
	sort(c, c + N);

	for (int i = 0; i < N; i++)
	{
		if(A[i] == c[N-1]) cout << c[N-2] << endl;
		else cout << c[N-1] << endl;
	}

	return 0;
}
