n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
d = 0
if n == k:
    print(max(0,sum(a)))
    exit()
for i in range(k,n):
    if a[i] > 0:
        d += a[i]
now = 0

for i in range(n):
    now += a[i]
    if i >= k:
        now -= a[i-k]
        if a[i] >= 0:
            d -= a[i]
        if a[i-k] >= 0:
            d += a[i-k]
        ans = max(ans,d+max(0,now))
    
print(ans)