n, k = map(int, input().split())
a = list(map(int, input().split()))

plus_a = [0] * n
minus_a = [0] * n
ans = 0
for i in range(n):
    if a[i] > 0:
        plus_a[i] = a[i]
    else:
        minus_a[i] = a[i]
    ans += plus_a[i]

ruiseki_plus = [0] * (n + 1)
ruiseki_minus = [0] * (n + 1)
for i in range(n):
    ruiseki_plus[i+1] = ruiseki_plus[i] + plus_a[i]
    ruiseki_minus[i+1] = ruiseki_minus[i] + minus_a[i]

min_decreasing = -float("inf")
for i in range(n-k+1):
    #黒で塗る場合
    tmp_plus = ruiseki_plus[i+k] - ruiseki_plus[i]
    tmp_minus = ruiseki_minus[i+k] - ruiseki_minus[i]
    min_decreasing = max(min_decreasing, -tmp_plus, tmp_minus)

print(ans + min_decreasing)