~/algor $ cat problems/minmax-38-k-ta-qoshni-eng-katta-yigindi
Largest sum of K adjacent
Medium
1000 ms
128 MB
64%
Positive integers $N$, $K$ and $N$ integers are given. Find the largest value of the sum of $K$ consecutive elements
$$A_{i} + A_{i + 1} + \ldots + A_{i + K - 1}, \qquad 1 \le i \le N - K + 1$$
Input
The first line contains two positive integers: $N$ and $K$. The next line contains $N$ integers $A_{i}$.
Output
One integer.
Note
$1 \le K \le N \le 10^{5}$
$-10^{9} \le A_{i} \le 10^{9}$
Examples
Input #1
7 3 2 6 1 5 4 3 7
Output #1
14
Input #2
3 3 -1 4 -2
Output #2
1