/* C */

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int n;
	cin >> n;

	int a;
	int k = 0;

	int max1 = 0, max2 = 0;

	for (int i = 0; i < n; ++i)
	{
		cin >> a;
		if(a >= max1) max1 = a;
		if((a => max2) && (a < max1)){
			max2 = a;
			k = i;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		if(i != k) cout << max1 << max1;
		else cout << max2 << endl;
	}

}