n, k = map(int, input().split())
a = list(map(int, input().split()))
sum_a = [0]
for ai in a:
    sum_a.append(sum_a[-1] + (ai if ai > 0 else 0))
sum_sk = sum(a[:k])
ans = max(sum_sk + sum_a[n] - sum_a[k], sum_a[n] - sum_a[k])
for i in range(n - k):
    sum_sk = sum_sk - a[i] + a[i + k]
    ans = max(ans,
              sum_sk + sum_a[n] - (sum_a[i + k + 1] - sum_a[i + 1]),  # 黒色
              sum_a[n] - (sum_a[i + k + 1] - sum_a[i + 1]))  # 白色
print(ans)