#include <iostream>
#include <vector>
using namespace std ;
int main(){
    int n, s;
    vector<int> a(n) ;
    vector<int> b(s) ;
    cin << n ;
    for(int i = 0;i < n; i++){
        cin >> a.at(i)  ;
        b.at(i) = a.at(i) ;

    }
    //二列！
    for(int i = 0;i < n; i++){
        for(int x = 0; x < n-1; x++){
            for(int y = x + 1; y < n; y++){
                if(a.at(y) > a.at(x)){
                    int m = a.at(y) ;
                    a.at(y) = a.at(x) ;
                    a.at(x) = m ;
                }
            }
        }
    }
    
    for(int i =0; i < n; i++){
        if(b.at(i) == a.at(0)){
        cout << a.at(1)  << endl ;
        }
        if(b.at(i) != a.at(0)){
            cout << a.at(0) << endl ;
        }
    }


    return 0;
}