N,K = map(int,input().split())
A = list(map(int,input().split()))
Acu = [0]
Acu_p = [0]
for i in range(N):
  if i == 0:
    Acu.append(A[i])
  else:
    Acu.append(A[i]+Acu[-1])
#print(Acu)
for i in range(N):
  if i == 0:
    Acu_p.append(max(A[i],0))
  else:
    Acu_p.append(max(A[i],0)+Acu_p[-1])
#print(Acu_p)
ans = -float("inf")
for i in range(N-K+1):
  tmp = Acu_p[-1]
  tmp += max(Acu[i+K]-Acu[i],0)
  tmp -= Acu_p[i+K]-Acu_p[i]
  ans = max(ans,tmp)
print(ans)