N, K = list(map(int,input().split()))
a = list(map(int,input().split()))
# N,K=10,5
# a=[5,-4,-5,-8,-4,7,2,-4,0,7]

b = []
w = []
riso = []

risonow = sum([a[i] for i in range(K) if a[i]>0])
riso.append(risonow)
bnow = sum([-a[i] for i in range(K) if a[i]<0])
b.append(bnow)

for i in range(K,N):
	if a[i]>0:
		risonow+=a[i]
	else:
		bnow+=-a[i]
	if a[i-K]>0:
		risonow-=a[i-K]
	else:
		bnow-=-a[i-K]
	riso.append(risonow)
	b.append(bnow)

riso.extend(b)
print(sum([i for i in a if i>0])-min(riso))
