n,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
x,y,ans = [0],[0],0
for i in range(n):
	x.append(x[-1]+a[i])
	y.append(y[-1]+max(0,a[i]))
for i in range(1,n-k+2):
	num,num2 = y[i-1]+y[n]-y[i+k-1],x[i+k-1]-x[i-1]
	ans = max(ans,num,num+num2)
print(ans)