#C6495. Second Maximum Value

    ID: 50261 Type: Default 1000ms 256MiB

Second Maximum Value

Second Maximum Value

Given a list of distinct integers, your task is to find the second maximum value in the list.

The input consists of a number n on the first line, indicating the number of integers, followed by a line containing n distinct integers separated by spaces. It is guaranteed that n \geq 2. If this condition is not met, your program should output an error message.

In mathematical terms, if the sorted list in descending order is \( a_1, a_2, \ldots, a_n \) then you must output \( a_2 \), the second largest element.

inputFormat

The first line contains an integer n (\( n \geq 2 \)), the number of elements in the list.

The second line contains n distinct integers separated by spaces.

outputFormat

Output a single line containing the second maximum integer from the list.

## sample
5
1 2 3 4 5
4

</p>