N, K = map(int, input().split())
A = list(map(int, input().split()))
b = sum([i for i in A[:K] if i <= 0])
bMax = b
w = sum([i for i in A[:K] if i >= 0])
wMin = w
for i in range(N-K):
    b = b - min(A[i], 0) + min(A[K+i], 0)
    w = w - max(A[i], 0) + max(A[K+i], 0)
    bMax = max(bMax, b)
    wMin = min(wMin, w)
print(sum(i for i in A if i >= 0) + max(bMax, -wMin))
