if __name__ == '__main__':
    n = int(input())
    arr = map(int, input().split())
    scores = list(arr)
    scores.sort()
    scores_minus_duplicates = list(dict.fromkeys(scores))
    print(scores_minus_duplicates[-2])

051fc38d15dd0e1e3b04cd4bb2aa55152c2c9ace
<mask token>

if __name__ == '__main__':
    n = int(input())
    arr = map(int, input().split())
    scores = list(arr)
    scores.sort()
    scores_minus_duplicates = list(dict.fromkeys(scores))
    print(scores_minus_duplicates[-2])
