Maximum Sum Of M Non-overlapping Subarrays

hard
1. You are given an array(arr) of positive numbers and two numbers M and K.
2. You have to find the maximum sum of M non-overlapping subarrays of size K.
3. The size of the given array(arr) is greater than M*K.

Input Format

A number N arr1 arr2.. N numbers Two numbers M and K

Output Format

A number representing maximum sum of M non-overlapping subarrays of size K.

Constraints

1 <= N <= 10^3
1 <= arr[i] <= 10^3
M >= 1
K >= 1
N >= M*K

Example

Input
7
2 10 7 18 5 33 0
3
1
Output
61
Previous
Maximum Sum Of Three Non-overlapping Subarrays
Next
Number Of Ways Of Triangulation

Related Questions