#include<bits/stdc++.h>
using namespace std;

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