n,k = map(int, input().split())
a = list(map(int, input().split()))
ideal = 0
imos_b = sum([v for v in a[0:k]])
imos_w = sum([v if v>0 else 0 for v in a[0:k]])
right_b = [0 for i in range(n-k+1)]
right_w = [0 for i in range(n-k+1)]
for i,v in enumerate(a):
    if v>0:
        ideal += v
    if i < n-k+1:
        right_b[i] = imos_b
        right_w[i] = imos_w
        imos_b -= a[i]
        imos_w -= a[i] if a[i]>0 else 0
    if i < n-k:
        imos_b += a[i+k]
        imos_w += a[i+k] if a[i+k]>0 else 0
max_score = sum(a)
for i in range(n-k+1):
    max_score = max(max_score, ideal+right_b[i]-right_w[i], ideal-right_w[i])
print(max_score)

