n,k=map(int,input().split())
a=list(map(int,input().split()))

L=[0]
for i in range(n):
  L.append(L[i]+a[i])

L2=[0]
for i in range(n):
  L2.append(L2[i]+max(0,a[i]))

ans=[]
for i in range(n-k+1):
  x=L[i+k]-L[i]
  y=L2[n]-L2[i+k]+L2[i]
  ans.append(max(y,x+y))
print(max(ans))