#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
const long long INF = 1LL<<60;


int main(){	
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	vector<int> ans(N);
	ans = A;
	sort(A.begin(),A.end());
	for(int i = 0; i < N; i++){
		if(ans[i] == max){
			cout << A[N-2] << endl;
		}else{
			cout << A[N-1] << endl;
		}

	}
}