n,k = map(int,input().split())
a = list(map(int,input().split()))
rui = [0]*(n+1)
wa = 0
for i in range(n):
  rui[i+1] = rui[i] + a[i]
pura = 0
for i in range(n-k):
  if a[i] >0:
    pura += a[i]
for i in range(n-k,-1,-1):
  wa = max(pura+rui[i+k]-rui[i],pura,wa)
  if a[i-1] >0:
    pura -= a[i-1]
  if a[i+k-1]>0:
    pura += a[i+k-1]
print(wa)