import sys
input = sys.stdin.readline
n,k = map(int,input().split())
A = list(map(int,input().split()))

s = sum(A[:k])
t = 0
for i in range(k):
    t += max(A[i], 0)
a = min(t-s, t)
ai = 0
b = 1 if t > t-s else 0
# print(a)
for i in range(1, n-k+1):
    s -= A[i-1]
    s += A[i+k-1]
    t -= max(A[i-1], 0)
    t += max(A[i+k-1], 0)
    if a > t:
        a = t
        ai = i
        b = 0
    if a > t-s:
        a = t-s
        ai = i
        b = 1

ans = 0
# print(a,ai,b)

for i in range(0, ai):
    ans += max(0, A[i])
for i in range(ai+k, n):
    ans += max(0, A[i])

if b > 0:
    ans += sum(A[ai:ai+k])

print(ans)