#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a;
  vector<int> b(a);
  vector<int> c(a);
  lp(i,a){
    cin>>b(i);
    c(i)=b(i);
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  lp(i,a){
    if(c.at(0)==b.at(i))cout<<c.at(1)<<endl;
    else cout<<c.at(0)<<endl;
  }
}
