#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{int n,i,j,a[200100],b[200100];
scanf("%d",&n);
  for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
    b[i]=a[i];}
    sort(a,a+n);
    for(j=0;j<n;j++)  
    if(b[j]!=a[n-1])printf("%d\n",a[n-1]);
      else printf("%d\n",a[n-2]);


}