#Q178. 「一本通 5.5 例 2」最大连续和

「一本通 5.5 例 2」最大连续和

Description

You are given an integer sequence {A1,A2,,An}\{A_1, A_2, \cdots, A_n\} of length nn. Your task is to find a non-empty contiguous subsequence with a length not exceeding mm such that the sum of this subsequence is maximized.

Input Format

The first line contains two integers nn and mm;

The second line contains nn integers separated by spaces, where the absolute value of each number is less than 10001000.

Output Format

Output a single integer representing the maximum sum of a non-empty contiguous subsequence with length not exceeding mm.

Sample 1

6 4
1 -3 5 1 -2 3

7

Constraints & Hints

For 50%50\% of the test cases, 1n,m1041 \le n, m \le 10^4;

For 100%100\% of the test cases, 1n,m2×1051 \le n, m \le 2 \times 10^5.