Top Three ScoresEasy

Top Three Scores

EasyPractice library · +10 XPheapssortingtop-k

Given a list of integer scores, find the three highest distinct scores. If there are fewer than three distinct scores, print all distinct scores in descending order. Print the scores separated by spaces. If there are ties for the third highest score, include all scores equal to the third highest.

Input

The first line contains an integer N, the number of scores. The second line contains N space-separated integers representing the scores.

Output

Print the top three distinct scores in descending order, separated by spaces. If there are fewer than three distinct scores, print all distinct scores in descending order.

Constraints

1 <= N <= 1000. Each score will be an integer between 0 and 10^9.

Time limit 1 s (native code; slower languages get more)Memory 256 MB15 hidden tests

Example 1

Input
7
80 90 70 100 85 95 75
Output
100 95 90

The distinct scores are 70, 75, 80, 85, 90, 95, 100. The top three are 100, 95, 90.

Example 2

Input
5
100 100 100 100 100
Output
100

There is only one distinct score: 100.

Hints