1if __name__ == '__main__':
2 n = int(input())
3 arr = map(int, input().split())
4 arr = list(arr)
5 x = max(arr)
6 y = -9999999
7 for i in range(0,n):
8 if arr[i]<x and arr[i] > y:
9 y = arr[i]
10
11 print(y)
12