#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a;
  vector<int> b;
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
    b.push_back(tmp);
    a.push_back(tmp);
  }
  sort(a.begin(),a.end(),Greater<int>());
  for(int i = 0; n > i; i++){
    if(b[i]!=a[0]){
      cout << a[0] << endl;
    }else{
      cout << a[1] << endl;
    }
  }
}
  