from collections import deque

n, k = map(int, input().split())
a = list(map(int, input().split()))
q = deque(a[:k])
plus = cur_plus = min_plus = sum(x for x in q if x > 0)
cur_minus = max_minus = sum(q) - plus
for b in a[k:]:
    c = q.popleft()
    q.append(b)
    if b > 0:
        plus += b
        cur_plus += b
    else:
        cur_minus += b
    if c > 0:
        cur_plus -= c
    else:
        cur_minus -= c
    max_minus = max(max_minus, cur_minus)
    min_plus = min(min_plus, cur_plus)
print(max(plus + max_minus, plus - min_plus))
