LogiQuest

51. Second Largest Distinct Element

EasyArray

Print the second largest distinct value in the array, or -1 if all values are equal.

Input format

Line 1: n Line 2: n integers

Output format

The second largest distinct value, or -1.

Example 1

Input

5
2 9 4 9 7

Output

7

Example 2

Input

3
5 5 5

Output

-1

Constraints

1 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.

Loading the MyLoginn IDE…