#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    //ll P , Q , R;
    //cin >> P >> Q  >> R;

    ll N;
    cin >> N ;
    vector<ll > A(N,0);
    //cout << 3 * pow(A,2) << endl;

    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    for(int i = 0; i < N; i++){
        vector<ll > result;
        for(int j = 0; j < N; j++){
            if(j != i){
                result.push_back(A[j]);
            }
        }
        result.erase(unique(result.begin(), result.end()), result.end());
        sort(result.rbegin(), result.rend());
        if(result.size() == 1){
            cout << result[0] << endl;
            continue;
        }
        cout << result[0] << endl;
    }


}