#include<iostream>
#unclude<algorithm>

using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n],b[i];
  for(int i=0;i<n;i++){
    cin>>a[i];
    
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    if(b[i]==a[n-1]) cout << a[n-2] << endl;
    else cout << a[n-1] << endl;
  }
}