N, K = map(int, input().split())
a = list(map(int, input().split()))

a_plus = []
a_minus = []
for i in range(N):
    if i == 0:
        if a[i] > 0:
            a_plus.append(a[i])
            a_minus.append(0)
        else:
            a_plus.append(0)
            a_minus.append(a[i])
    else:
        if a[i] > 0:
            a_plus.append(a_plus[i-1] + a[i])
            a_minus.append(a_minus[i-1])
        else:
            a_plus.append(a_plus[i-1])
            a_minus.append(a_minus[i-1] + a[i])

ans = 0
for i in range(N-K):
    ans = max(ans, a_plus[N-1] + (a_minus[i+K] - a_minus[i]), a_plus[N-1] - (a_plus[i+K] - a_plus[i]))
print(ans)
