n,k = map(int,input().split())
a = list(map(int,input().split()))
sum_a = [0]
for x in a:
    sum_a.append(sum_a[-1]+x)

ans = 0
ideal_a = [0]
for x in a:
    ideal_a.append(ideal_a[-1]+max(0,x))

for i in range(n-k+1):
    t = max(0,sum_a[i+k]-sum_a[i]) + ideal_a[n]-ideal_a[k+i]+ideal_a[i]
    #print(t)
    ans = max(t,ans)

print(ans)