Skip to content
UPEEC

Second Largest

Easy#arrays· solved by 0 · time limit 2.0 s

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

Input

nn, then nn integers.

Output

The second largest distinct value.

Constraints

1≤n≤1051 \le n \le 10^5, ∣ai∣≤109|a_i| \le 10^9

Sample 1

Input

4
3 7 7 2

Output

3

Sample 2

Input

2
4 4

Output

-1

Sign in or join free to run and submit your solution.