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

p = [0] * (n + 1)
m = [0] * (n + 1)
for i in range(n):
    if a[i] > 0:
        p[i + 1] = p[i] + a[i]
        m[i + 1] = m[i]
    else:
        p[i + 1] = p[i]
        m[i + 1] = m[i] + a[i]

pmin = p[k] - p[0]
mmax = m[k] - m[0]

for i in range(1, n - k + 1):
    pmin = min(pmin, p[i + k] - p[i])
    mmax = max(mmax, m[i + k] - m[i])

ans = p[n] - min(pmin, -mmax)

print(ans)

