N = int(input())
A = [int(input()) for i in range(N)]
A_m = str(max(A))
a = A.index(int(A_m))
A = sorted(A)
if A.count(int(A_m)) >= 2:
    print((A_m + '\n')*N)
else:
    print(a)
    print((A_m + '\n')*a + str(A[-2]))
    print((A_m + '\n')*(N-(a+1)))
