Problem:
You are given an array a1,a2,…,an and two integers m and k.
You can choose some subarray al,al+1,…,ar−1,ar.
The cost of subarray al,al+1,…,ar−1,ar is equal to i=l∑rai−k⌈mr−l+1⌉, where ⌈x⌉ is the least integer greater than or equal to x.
The cost of empty subarray is equal to zero.
For example, if m=3, k=10 and a=[2,−4,15,−3,4,8,3], then the cost of some subarrays are:
- a3…a3:15−k⌈31⌉=15−10=5;
- a3…a4:(15−3)−k⌈32⌉=12−10=2;
- a3…a5:(15−3+4)−k⌈33⌉=16−10=6;
- a3…a6:(15−3+4+8)−k⌈34⌉=24−20=4;
- a3…a7:(15−3+4+8+3)−k⌈35⌉=27−20=7.
Your task is to find the maximum cost of some subarray (possibly empty) of array a.
Input Format:
The first line contains three integers n, m, and k (1≤n≤3⋅105,1≤m≤10,1≤k≤109).
The second line contains n integers a1,a2,…,an (−109≤ai≤109).
Output Format:
Print the maximum cost of some subarray of array a.