n,k=map(int,input().split())
a=list(map(int,input().split()))
base=sum([x for x in a if x>0])
black=sum([-x for x in a[:k] if x<0])
white=sum([x for x in a[:k] if x>0])
ans=max(0,base-min(black,white))
for i in range(k,n):
  if a[i]>0:
    white+=a[i]
  else:
    black-=a[i]
  if a[i-k]>0:
    white-=a[i-k]
  else:
    black+=a[i-k]
  ans=max(ans,base-min(black,white))
  #print(black,white)
print(ans)
