import numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = np.array(a)
cs = np.cumsum((a > 0) * a)
cs = [0] + list(cs)
results = []
for i in range(k, n + 1):
    results.append(cs[i] - cs[i - k])

index = np.argmin(results)
minv = (cs[-1] - min(results) + max(sum(a[index: index + k]), 0))
index = np.argmax(results)
maxv = (cs[-1] - max(results) + max(sum(a[index: index + k]), 0))
print(max(minv, maxv))

