N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
ans, mi = 0, -1
for i in range(N-K+1):
    ans, mi = max(ans, sum(A[i:i+K])), i
if mi != -1:
    for i in range(N):
        if mi <= i < mi + K:
            continue
        ans += max(0, A[i])
print ans
