n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]
c=[0]
for i in a:
  b.append(b[-1]+i)
  c.append(c[-1]+max(0,i))
ans=-float('inf')
for i in range(n-k+1):
  x=b[i+k]-b[i]
  y=c[n]-c[i+k]+c[i]
  ans=max(ans,y+max(0,x))
print(ans)