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

int N,A[200000+10],B[200000+10];

signed main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
    B[i]=A[i];
  }
  sort(A,A+N);
  for(int i=0;i<N;i++){
    if(B[i]==A[N-1]) cout << A[N-2] << endl;
    else cout << A[N-1] << endl;
  }
  return 0;
}
