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

a_sort = sorted(a, reverse=True)
max1 = a_sort[0]
max2 = a_sort[1]
for x in a:
        if a.count(max1) > 1:
                print(max1)
        else: 
                if x != max1:
                        print(max1)
                else:
                        print(max2)
