#include<iostream>
#include<deque>
#include<algorithm>
using namespace std;

int main() {
	size_t c; cin >> c;
	deque<int> l(c);
	for (size_t i = 0; i < c; ++i)
		cin >> l.at(i);
	auto k = l;
	sort(k.begin(), k.end());
	for (int i = 0; i < c; ++i) {
		cout << ((l.at(i) == k.at(c-1)) ? k.at(c-2) : k.at(c-1)) << endl;
	}
}