#!/usr/bin/python

n = raw_input()
a = map(int, raw_input().strip().split(' '))
largest = None

for v in sorted(a, reverse=True):
    if not largest:
        largest = v
    elif largest != v:
        print v
        break

952a659c3718e9ba1c87411c2a83415ec5c1b900
#!/usr/bin/python

n = raw_input()
a = map(int, raw_input().strip().split(' '))
largest = None

for v in sorted(a, reverse=True):
    if not largest:
        largest = v
    elif largest != v:
        print v
        break
