from sys import stdin

n = int(stdin.readline().rstrip())
li = list(int(stdin.readline().rstrip()) for _ in range(n))

for i in range(n-1):
    if max(li) == li[i]:
        if i == 0:
            a = [0]
            b = li[i+1:]
        else:
            a = li[:i]
            b = li[i+1:]
    else:
        print(max(li))
print(max(li[:n]))   