n = int(input())
a = []
print('n a',n,a)
for i in range(n):
	a.append(int(input()))
print('As',a)
max1 = max(a)
location1 = a.index(max1)
print('1st MAX',max1,'INDEX',location1)
a.remove(a[location1])
max2 = max(a)
print('2nd MAX',max2)
if max1 == max2:
    print('1=2')
    for i in range(n):
        print(max1)
else:
    print('1!=2')
    for i in range(n):
    	if i == location1:
            print(max2)
        else:
            print(max1)