n, k = map(int, input().split())
A = list(map(int, input().split()))
B = [max(0, a) for a in A]

from itertools import accumulate
A = [0]+A
A = list(accumulate(A))
B = [0]+B
B = list(accumulate(B))

#print(A)
#print(B)

ans = -10**18
for i in range(n-k+1):
    temp = max(0, A[i+k]-A[i])
    temp += B[i]-B[0]
    temp += B[-1]-B[i+k]
    #print(i,  A[i+k]-A[i], B[i]-B[0], B[-1]-B[i+k])
    ans = max(ans, temp)
print(ans)
