N, K = map(int, input().split())
a = list(map(int, input().split()))

band = sum(a[:K])
other = 0
for i in range(K, N):
    other += max(0, a[i])
ans = max(band, 0) + other
for i in range(N - K):
    band -= a[i]
    band += a[K + i]
    other += max(a[i], 0)
    other -= max(a[K + i], 0)
    ans = max(ans, max(band, 0) + other)
print(ans)
