N = int(input())
li = []
max1 = 0
max2 = 0
for i in range(N):
  s = int(input())
  li.append(s)
  
  if s > max1:
    max1 = s
    
  if max1 > s > max2:
    max2 = s

for index, i in enumerate(li):
  s = max(li)
  
  if s == li[index]:
    print(max2)
  else:
    print(max1)