Description
There are $N$ candies lined up in a horizontal row on a desk, numbered from $1$ to $N$ from left to right. The deliciousness of candy $i$ ($1 \le i \le N$) is $A_i$.
JOI-kun decided to choose some of the $N$ candies and eat them.
However, in order not to eat too many candies, for any $K$ consecutive candies, he eats at most $2$ of them. In other words, for every $j$ ($1 \le j \le N - K + 1$), among the $K$ consecutive candies from candy $j$ to candy $j + K - 1$, the number of candies he eats must be at most $2$.
Under this condition, JOI-kun wants to maximize the total deliciousness of the candies he eats.
Given the deliciousness of the $N$ candies and $K$, write a program to find the maximum possible total deliciousness of the candies JOI-kun eats.
Constraints
- $2 \le K \le N \le 3\,000$.
- $1 \le A_i \le 10^9$ ($1 \le i \le N$).
- All input values are integers.
Subtasks
- ($4$ points) $N \le 20$.
- ($19$ points) $K \le 10$.
- ($47$ points) $N \le 300$.
- ($30$ points) No additional constraints.
Input
The input is given from standard input in the following format:
N K A_1 A_2 ... A_N
Output
To standard output, output in $1$ line the maximum possible total deliciousness of the candies JOI-kun eats.
Sample I/O
Sample Input 1
5 4 1 3 2 4 3
Sample Output 1
8
When JOI-kun eats candy $1$, candy $4$, and candy $5$, the total deliciousness is $8$.
Among the ways of eating candies such that at most $2$ candies are eaten from any $4$ consecutive candies, there is none with a total deliciousness of $9$ or more, so output $8$.
This sample input satisfies the constraints of all subtasks.
Sample Input 2
6 3 3 7 1 5 6 4
Sample Output 2
21
When JOI-kun eats candy $1$, candy $2$, candy $4$, and candy $5$, the total deliciousness is $21$.
Among the ways of eating candies such that at most $2$ candies are eaten from any $3$ consecutive candies, there is none with a total deliciousness of $22$ or more, so output $21$.
This sample input satisfies the constraints of all subtasks.
Sample Input 3
5 2 3 3 2 2 1
Sample Output 3
11
This sample input satisfies the constraints of all subtasks.
Sample Input 4
12 5 864814169 716638377 926889183 891468826 217138351 891972397 504371916 678159995 435478604 181254225 760822841 688502728
Sample Output 4
4427122428
This sample input satisfies the constraints of all subtasks.