Problems > Second Largest Value

Second Largest Value

Difficulty: 1000 2000 ms 128 MB

implementation

Print the second largest distinct value of the list. If all values are equal, print NONE.

Input: the first line has an integer N; the second line has N integers separated by spaces.

Output: the second largest distinct value, or NONE.

Constraints:

  • 1 ≤ N ≤ 2000
  • −109 ≤ ai ≤ 109

Sample Tests

Input 1
5
3 9 4 9 2
Output 1
4
Input 2
3
5 5 5
Output 2
NONE

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.