n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=sum([x for x in a if x>0])
np=sum([x for x in a[:k] if x>0])
nm=sum([-x for x in a[:k] if x<0])
ansb=nm
answ=np
# ansb:黒に塗った時、理想値からの差分
# answ:白に塗った時、理想値からの差分
for i in range(k,n):
  x=a[i]
  if x>0:
    np+=x
  else:
    nm-=x
  y=a[i-k]
  if y>0:
    np-=y
  else:
    nm+=y
  ansb=min(ansb,np)
  answ=min(answ,nm)
print(ans-min(ansb,answ))
  

