#include <iostream>
#include <algorithm>
using namespace std;
const int N = 2e5+250;
int n,i,a[N],b[N];
int main()
{
    cin>>n;
    for (i=1;i<=n;++i)
        cin>>a[i],b[i]=a[i];
    sort(a+1,a+n+1,greater<int>());
    for (i=1;i<=n;++i)
    {
        if (b[i]==a[1]) cout<<a[2]<<"\n";
        else cout<<a[1]<<"\n";
    }
}


