#C13948. Maximum Contiguous Sublist Sum

    ID: 43542 Type: Default 1000ms 256MiB

Maximum Contiguous Sublist Sum

Maximum Contiguous Sublist Sum

You are given an array of n integers and an integer k. Your task is to determine the maximum sum of any contiguous subarray of length k.

If k is less than or equal to 0 or greater than n, then the answer is defined as 0.

The mathematical formulation of the problem can be given as follows:

\[ \max_{0 \le i \le n-k}\left(\sum_{j=i}^{i+k-1} a_j\right), \quad \text{if } 0

inputFormat

The first line contains an integer n representing the number of elements in the array.

The second line contains n space-separated integers denoting the elements of the array.

The third line contains an integer k representing the length of the contiguous subarray.

outputFormat

Output a single integer which is the maximum sum of any contiguous subarray of length k. If k is zero or greater than n, output 0.

## sample
5
1 2 3 4 5
2
9