from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,K = inpl()
aa  = inpl()

SUM_aa = [0]
ABS_aa = [0]
tmp1 = tmp2 = 0
for a in aa:
	tmp1 += a
	tmp2 += max(a,0)
	SUM_aa.append(tmp1)
	ABS_aa.append(tmp2)

SUM = ABS_aa[N]
ans = 0
for i in range(N-K+1):
	left = ABS_aa[i]
	right = SUM - ABS_aa[i+K]
	mid = SUM_aa[i+K]-SUM_aa[i]
	ans = max(ans,left+right+max(0,mid))

print(ans)
