IntermediateRating 1300
Take Cards From the Ends
Cards lie in a row. You take exactly k cards, each from the left end or the right end. Print the largest total you can collect.
Input
n and k, then n card values.
Output
One integer.
Sample 1
Input
7 3 1 2 3 4 5 6 1
Output
12
Sample 2
Input
3 2 2 2 2
Output
4
Output appears here