#include<bits/stdc++.h>
using namespace std;

int main()
{
int t,i;
cin>>t;
int arr[t],arr1[t];
for(i=0;i<t;i++)
{
    cin>>arr[i];
    arr1[i]=arr[i];
}



   sort(arr,arr+t,greater<int>());
for(i=0;i<t;i++)
{
    if(arr1[i]==arr[0])
    cout<<arr[1]<<endl;
   else
    cout<<arr[0]<<endl;
}



 return 0;

}


