from collections import deque

n, k = map(int, input().split())
a = list(map(int, input().split()))
q = deque(a[:k])
max_ = min_ = c = sum(q)
plus = plus_in_max = plus_in_min = sum(x for x in q if x > 0)
for b in a[k:]:
    c -= q.popleft()
    c += b
    q.append(b)
    if max_ < c:
        max_ = c
        plus_in_max = sum(x for x in q if x > 0)
    if min_ > c:
        min_ = c
        plus_in_min = sum(x for x in q if x > 0)
    if b > 0:
        plus += b
print(max(plus + max_ - plus_in_max, plus - plus_in_min))
