import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



n,k = map(int, input().split())
a = list(map(int, input().split()))

# 累積和
def cumsum(a, pos=False):
    """l[i] = sum(a[:i]) なるlを返す
    sum(a[i:j]) == l[j+1] - l[i]
    """
    c = 0
    l = [None] * (len(a)+1)
    for i,num in enumerate(a):
        l[i] = c
        c += num if not pos else max(0, num)
    l[-1] = c
    return l

ca = cumsum(a)
pca = cumsum(a, pos=True)
ans = 0
for i in range(0, n-k+1):
    ans = max(ans, pca[i] + max(0,ca[i+k]-ca[i]) + (pca[n]-pca[i+k]))
print(ans)