a = int(input()) k = [] n = 0 k = input().split() k.sort() """for i in k: if (i > n): n = i""" print(k[a-2])