Santa Claus' most expensive gifts
Totos had a very strange dream last night. In his dream he was Santa's elf and he even had the role of loading all the children's the presents into Santa's sack!
Like the sly and mischievous boy he is (even in his sleep), he did the following: After finding out the value of all the presents that Santa would distribute, he made sure to put in the sack the most expensive ones first, in order from most to least expensive, and afterwards, all the other presents. He had the secret hope, you see, that at least these would be left over. This way he would keep the most expensive of all for himself, the next most expensive for his friend Annoula, and the third most expensive present he would keep to... sell!
Can you help Totos in the mischief of his dream?
We want to write a program that reads from the input STDIN
a positive integer , the number of presents in the bag, followed by positive integers , separated by a line feed character ('\n'
), denoting the value of each present.
The program will print at the output STDOUT
positive integers, separated by a line feed character ('\n'
), the values of the three most expensive presents, in the order in which Totos chooses them.
Constraints
- No present is worth more than North Pole dinars :-)
Examples
1st
STDIN
3
1
2
3
STDOUT
3
2
1
2nd
STDIN
8
10
1
9
3
10
8
1
11
STDOUT
11
10
10
Comments