# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = lr()
streak = N
neg_max = N
for i in range(N):
    if A[i] <= 0:
        streak += 1
    else:
        neg_max = min(neg_max, streak)
        streak = 0

Anp = np.array(A)
positive_sum = Anp[Anp>0].sum()
answer = - 10 ** 15
if neg_max >= K:
    answer = positive_sum
else:    
    for i in range(N-K+1):
        B = Anp[i:i+K]
        temp = positive_sum + B[B<0].sum()
        if temp > answer:
            answer = temp

print(answer)
# 54