#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,d;
  int b[100000],c[100000];;
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
    c[i]=b[i];
  }
  sort(b,b+a,greater<int>());
  for(int i=0;i<a;i++){
    d=0;
    if(b[0]!=c[i]){
      cout<<b[0]<<"\n";
      d=1;
    }
    if(b[0]==c[i]&&d==0||b[0]==c[i]){
      cout<<b[1]<<"\n";
    }
  }
  return(0);
}
