It's christmas morning! Time to open the gifts under the christmas tree.
You are given gifts, the gift initially having a happiness value of . Some gifts may have a positive happiness value, while others might have a negative happiness value! (or zero, for that matter).
In one move, you can either use your magic powers to flip the sign of one of the gift's happiness values OR you can open a gift. Your final score is the sum of the happiness values of all the gifts you open. If you don't open any gifts, your score is .
What is the maximum happiness score you can achieve in moves or less?
Constraints
Input Specification
The first line of input contains two integers, and , the number of gifts and the number of moves you can make.
The next line of input contains space-separated integers, , the initial happiness values of the gifts.
Output Specification
Output one line containing a single integer, the maximum happiness score you can achieve in moves or less.
Sample Input 1
5 4
1 2 -6 -2 3
Sample Output 1
11
Explanation for Sample 1
One possible solution is to use 1 move to flip the sign of -6, then use the remaining 3 moves to open the presents with happiness value 2,3 and 6. The happiness score from this approach is . It can be shown that this is maximal.
Sample Input 2
3 1
-3 -1 -4
Sample Output 2
0
Explanation for Sample 2
Since you only have one move, you can either not use it, or open a gift. However, all of the gifts have negative happiness values! Thus, it is optimal to not open any gifts, for a final happiness score of .
Sample Input 3
3 3
1 1 -2
Sample Output 3
3
Sample Input 4
6 5
-7 4 -6 4 -9 -7
Sample Output 4
20
Comments