It's christmas morning! Time to open the gifts under the christmas tree.
You are given
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
Constraints
Input Specification
The first line of input contains two integers,
The next line of input contains
Output Specification
Output one line containing a single integer, the maximum happiness score you can achieve in
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
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