#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int ar[n],copy[n];
  for(int i=0;i<n;++i)
  {
    cin>>ar[i];
    copy[i]=ar[i];
  }
  sort(copy,copy+n,greater<int>());
  for(int i=0;i<n;++i)
  {
    if(ar[i]==copy[0]){cout<<copy[1]<<"\n";}
    else{cout<<copy[0]<<"\n";}
  }
}
  
