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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;++i){
        cin >> A[i];
    }
    int res[N]={0};
    for(int j=0;j<N;++j){
    for(int i=0;i<N;++i){
        if(i!=j){
        if(res[j]<=A[i]){
            res[j]=A[i];
        }
    }      
}
    }
    for(int i=0;i<N;++i){
        cout << res[i]<<endl;
    }
}