n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = sum(i for i in a if i > 0)

# 長さkの区間で全て白にするか黒にするか決める
max_sk = 0
min_sk = float('inf')
sum_sk = sum(a[:k])
ma = 0
mi = 0
for i in range(k, n):
    sum_sk = sum_sk - a[i - k] + a[i]
    if max_sk < sum_sk:
        max_sk = sum_sk
        ma = i
    if min_sk > sum_sk:
        min_sk = sum_sk
        mi = i

d_ma = sum(-ai for ai in a[ma - k + 1: ma + 1] if ai < 0)
d_mi = sum(ai for ai in a[mi - k + 1: mi + 1] if ai > 0)
print(ans - min(d_ma, d_mi))