n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]+a
for i in range(n):
  b[i+1]=min(b[i+1],0)
  b[i+1]+=b[i]
c=[0]+a
for i in range(n):
  c[i+1]=max(c[i+1],0)
  c[i+1]+=c[i]
m=sum(max(i,0)for i in a)
ans=[]
for i in range(n-k+1):
  s=b[i+k]-b[i]
  ss=c[i+k]-c[i]
  ans+=[m+s,m-ss]
print(max(ans))