n,k=map(int,input().split())
a=list(map(int,input().split()))
sum_a=[0]*n
b=[max(0,a[i]) for i in range(n)]
sum_b=[0]*n
sum_a[0]=a[0]
sum_b[0]=a[0]
for i in range(1,n):
  sum_a[i]=sum_a[i-1]+a[i]
  sum_b[i]=sum_b[i-1]+b[i]
ans=max(sum_a[k-1]+sum_b[n-1]-sum_b[k-1],sum_b[n-1]-sum_b[k-1])
ans=max(ans,0)
for i in range(k,n):
  ans=max(ans,sum_a[i]-sum_a[i-k]+sum_b[n-1]-sum_b[i]+sum_b[i-k])
  ans=max(ans,sum_b[n-1]-sum_b[i]+sum_b[i-k])
print(ans)