if __name__ == '__main__':
    n = int(raw_input())
    e = raw_input().split()
    arr = map(int, e)
    
    lis = set(arr)
    
    sortedArr = sorted(lis)
    
    print sortedArr[-2]

fc1fb7849fb59abf39bdb41ff2564004dee4fd73
if __name__ == '__main__':
    n = int(raw_input())
    e = raw_input().split()
    arr = map(int, e)
    
    lis = set(arr)
    
    sortedArr = sorted(lis)
    
    print sortedArr[-2]
