#include<iostream>
#include<vector>

using std::cout;
using std::cin;
using std::endl;
using std::vector;

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

