YuPenG the Penguin is back again! He has just returned from the long trip to Hong Kong to attend the IMO (In My Opinion) competition. However, being the math god and the savage that he is, he does not care about others' opinions nor does he feel that they matter. Because of this, he managed to get the gold medal for IMO (not related to the other IMO). To celebrate his achievement, when YuPenG returned to the South Pole, as the god and ruler of PengVille, he ordered all of his subjects to bring him a gift each. (What a corrupted penguin)
The subjects placed the gifts on a round table (YuPenG loves circles). Each of the gifts has a satisfaction value of which is how much YuPenG wants that gift. can also be negative as some subjects brought cheese and butter. (Eww!) However, there is a problem. YuPenG, as a penguin, does not have hands and have wings. Therefore, he can only grab up to contiguous gifts. YuPenG will also only go to the table and grab the gifts twice. (What a lazy Penguin). Being the greedy Penguin that he is, he would wish to have the maximum sum of all the gifts that he grabs. However, he feels that this simple mathematics is too trivial for him and has requested for you to write a program to find the maximum sum of the value of gifts that he can grab.
Input Specification
The first line of input will contain two integers, and . The next line will contain integers representing the array .
Output Specification
The output should contain a single line. The line should contain integer which represents the maximum amount of satisfaction that YuPenG can achieve.
Constraints
For all subtasks:
Subtask 1 [10%]
Subtask 2 [20%]
Subtask 3 [70%]
Sample Input
6 2
6 4 -10 5 -1 6
Sample Output
17
Explanation
YuPenG can grab the set of gifts of and which both are within 2 gifts which is the maximum amount of gifts he can grab. He cannot grab the set of as it is more than 2 gifts.
Comments