Advanced1900

Yet Another Subarray Problem

Codeforces
View on Codeforces
Time: 2 secondsMemory: 256 megabytes

You are given an array a_1, a_2, … , a_n and two integers m and k.

You can choose some subarray a_l, a_l+1, …, a_r-1, a_r.

The cost of subarray a_l, a_l+1, …, a_r-1, a_r is equal to Σ_i=l^r a_i - k r - l + 1m , 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:

Your task is to find the maximum cost of some subarray (possibly empty) of array a.

Input

The first line contains three integers n, m, and k (1 ≤ n ≤ 3 · 10^5, 1 ≤ m ≤ 10, 1 ≤ k ≤ 10^9).The second line contains n integers a_1, a_2, …, a_n (-10^9 ≤ a_i ≤ 10^9).

Output

Print the maximum cost of some subarray of array a.

Examples

Input
7 3 10 2 -4 15 -3 4 8 3
Output
7
Input
5 2 1000 -13 -4 -9 -20 -11
Output
0
dpgreedymath

Discussion

(0)
Sign in to join the discussion.
Loading editor...
0 online