#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,a[200000],b[200000];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(b[i]==a[n-1])cout<<a[n-2]<<endl;
        else cout<<a[n-1]<<endl;
    }
}
