#include <bits/stdc++.h>

using namespace std;
#define maxn 200005
int arr[maxn];
int main(void)
{
  int n;cin>>n;
  for(int i=1;i<=n;i++){ cin>>arr[i]; }
  for(int i=1;i<=n;i++{ //dont calculate which i-th
    int maxinum=0;
    for(int j=1;j<=n;j++){
      if(j==i) continue;
      if(arr[j]>maxinum) maxinum=arr[j];
    }
    cout<<maxinum<<endl;
  }
  return 0;
}
  