n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
wa = 0
wa2 = 0
for i in range(n):
    if a[i] > 0:
        wa += a[i]
for i in range(k):
    if a[i] > 0:
        wa -= a[i]
        wa2 += a[i]
    else:
        wa2 += a[i]
l = []
if wa2 > 0:
    l.append(wa+wa2)
else:
    l.append(wa)
for i in range(n-k):
    if a[i] > 0:
        wa += a[i]
        wa2 -= a[i]
    else:
        wa2 -= a[i]
    if a[i+k] > 0:
        wa -= a[i+k]
        wa2 += a[i+k]
    else:
        wa2 += a[i+k]
    if wa2 > 0:
        l.append(wa+wa2)
    else:
        l.append(wa)
print(max(l))