#include<bits/stdc++.h>
#define rep(i,n)for(int i=1;i<n+1;++i)
#include<string>
using namespace std;

int main() {
	long long n;
	cin >> n;
	vector<long long>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	vector<long long>s(n) = a(n);
	sort(s.begin(),s.end());
	rep(i, n) {
		if (a[i] == s[n])cout << s[n - 1] << endl;
		else cout << s[n] << endl;
	}
}