Second Largest (distinct)

MEDIUM-HARD · C · 3000ms

To choose the runner-up, Tanvir needs the second-highest DISTINCT score, since several projects tied for the top mark. Read N integers and print the second largest DISTINCT value. It is guaranteed at least 2 distinct values exist.

Input

First line N, second line N integers.

Output

The second largest distinct value.

Constraints

2 ≤ N ≤ 10^5

Sample Input

5
4 4 7 7 2

Sample Output

4
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Second Largest (distinct) · DIU ContestHub