is cooking up a stew for the annual Globgalab Christmas Festival!
In Globgalab City, ingredients are all given a flavour value. She has access to an assortment of tasty ingredients where each ingredient has a flavour value of . has determined that to achieve the right texture of stew she must use exactly ingredients.
Additionally, the tastiest stew will use ingredients with the smallest difference in flavour values, that is, the largest difference between two ingredients must be minimized to achieve the tastiest stew.
is having a tough time deciding which ingredients to choose so she has enlisted you with the task of choosing the best ingredients and finding the total flavour value of the ingredients. In the scenario where multiple combinations of ingredients will achieve the smallest difference in flavour values, output the answer in which the sum of the flavour values is maximized.Can you help her make the tastiest stew with ingredients?
Input Specification
The first line contains two space-separated integers
The second line contains integers, the flavour value of the ingredients,
Output Specification
Output a single integer, the sum of the flavour values whose ingredients make the tastiest stew.
Subtasks
Subtask 1 (20%)
Subtask 2 (80%)
No further constraints.
Sample Input
5 3
1 4 2 3 6
Sample Output
9
Comments