import heapq

num = int(input())
a = [int(input()) for i in range(num)]
b = [max(a) for f in range(num)]
if sorted(a)[0] == sorted(a)[1]:
  for j in b:
    print(j)
else:
  b[a.index(max(a))] = sorted(a)[1]
  for j in b:
    print(j)
