N, K = map(int, input().split())
A = list(map(int, input().split()))

# Kの連続する数列ひとつだけ黒か白に統一されている縛りがある
# ほかは任意なので、正は黒に、負は白にぬればよい

CumS = [0] * (N+1)
CumSPos = [0] * (N+1)

for i in range(N):
  CumS[i+1] = CumS[i] + A[i]
  CumSPos[i+1] = CumSPos[i] + (A[i] if A[i] > 0 else 0)

ans = (-1) * float("inf")
# i : 統一されてるシークエンスの始まりindex。1-indexed
for i in range(1,N+1): #1-index
  if i+K-1 > N:
    break
  work = 0
  work += CumSPos[i-1] # pos -> black, neg -> white
  work += max(CumS[i+K-1] - CumS[i-1], 0) # black or white
  work += CumSPos[N] - CumSPos[i+K-1]  # pos -> black, neg -> white
  ans = max(ans, work)
  #print(i,work, CumSPos[i-1], max(CumS[i+K-1] - CumS[i-1], 0), CumSPos[N] - CumSPos[i+K-1])
  
print(ans)