ai = lambda: list(map(int,input().split()))

n,k = ai()
a = ai()

sa = [0]
for i in range(n):
    sa.append(sa[-1]+a[i])

spa = [0]
for i in range(n):
    spa.append(spa[-1]+max(a[i], 0))

ans = -float('inf')
for i in range(n-k+1):
    ans = max(ans, max(0, sa[i+k]-sa[i]) + spa[i] + (spa[n]-spa[i+k]))
print(ans)
