#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	LL n;
	cin >>n;
	vector<LL> a(n);
	vector<LL> b(n);
	for (LL i = 0; i < n; i++) {
		cin >>a[i];
		b[i]=a[i];
	}

	sort(b.begin(),b.end(),greater<LL>());
	

	for (LL i = 0; i < n; i++) {
		if (a[i] == b[0]) {
			cout <<b[1]<<endl;
		}
		else {
			cout <<b[o]<<endl;
		}
	}


	return 0;
}