#C5360. Find the Second Largest Number

    ID: 49001 Type: Default 1000ms 256MiB

Find the Second Largest Number

Find the Second Largest Number

In this problem, you are given a list of integers and you need to determine the second largest distinct number. If there is no such number (i.e. if the list has fewer than two unique numbers), output None.

Mathematically, let ( S ) be the set of distinct integers from the given list. If (|S| < 2), then there is no second largest number; otherwise, if we sort (S) in descending order, the required answer is the element at index 1.

inputFormat

The input is read from stdin. The first line contains an integer n representing the number of elements in the list. The second line contains n space-separated integers.

outputFormat

Print the second largest distinct number to stdout. If there is no second largest number, print None.## sample

7
4 6 1 7 6 2 6
6