#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    ll Max = 0 , max = 0 , N , A;
    vector <int> t;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A;
        if(A > Max){
            max = Max;
            Max = A;
        }
        else if(A > Max * 2){
            max = A;
            t.push_back{A};
        }
    }
    for(int i = 0; i < N; i++){
        if(v.at(i) == Max){
            cout << Max << endl;
        }
        else{
            cout << max << endl;
        }
    }
    return 0;
}