# https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list/problem

if __name__ == '__main__':
    n = int(input())
    arr = map(int, input().split())
    l = list(set(arr))
    l.sort()
    l.reverse()
    print(l[1])