#!/usr/bin/env python3
N, K = map(int, input().split())
a = list(map(int, input().split()))

pl = [(x if (x > 0) else 0) for x in a]
ans = 0
if lambda x: x > 0 in a:
    for i in range(N - K + 1):
        ans = max(ans, max(0, sum(a[i:K + i])) + sum(pl[:i]) + sum(pl[K + i:]))
print(ans)
