#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int N;
  cin >>N;
  int A[N],B[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(A[N-1]==B[i])
      cout<<A[N-2]<<endl;
    else
      cout<<A[N-1]<<endl;
    
    }
  return 0;
}
