#K51267. Finding Second Extremes

    ID: 29050 Type: Default 1000ms 256MiB

Finding Second Extremes

Finding Second Extremes

You are given a list of integers. Your task is to find the second largest and the second smallest distinct numbers in the list.

Note: It is guaranteed that the list contains at least two distinct integers.

For example: If the input list is [4, 6, 2, 1, 9, 63, -134, 566], the distinct sorted order is [-134, 1, 2, 4, 6, 9, 63, 566]. The second largest number is 63 and the second smallest is 1.

inputFormat

The first line of input contains a single integer n denoting the number of integers.

The second line contains n space-separated integers.

outputFormat

Output two lines. The first line should contain the second largest distinct number, and the second line should contain the second smallest distinct number.

## sample
8
4 6 2 1 9 63 -134 566
63

1

</p>