It's almost Halloween! Adam has devised a plan to get the most out of trick or treating. However, he wants to make sure his plan works correctly, so he has asked you to make a program to check how much value he gets out of trick or treating.
Given candies, each candy with a value , he wants you to organize his bag so that he can get the greatest value!
Of course, each candy takes one unit of space, and in total he has units of space in his bag! He cannot always fit all the candies in his bag, so he will have to sometimes take candies out!
Input Specification
The first line will contain the integers and .
The following lines will contain the value of each candy.
Output Specification
On a single line, output the maximal value he can fit in his bag.
Sample Input
5 4
8
10
123
1
999
Sample Output
1140
Comments