n = int(input())
a = [int(input()) for x in range(n)]
x = max(a)

import copy

for i in range(n):
   if(a[i] < x):
      print(x)
   else:
      b = sorted(list(set(a)), reverse=True)
      if(len(b) == 1):
         print(x)
      else:
         print(b[1])
