n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]
for i in a:b.append(b[-1]+i)
m=b[k]
mi=0
for i in range(1,n-k+1):
  if m<b[i+k]-b[i]:
    m=b[i+k]-b[i]
    mi=i
ans=0
for i in range(n):
  if not(mi<=i<mi+k):ans+=max(0,a[i])
x=ans+m
m=b[k]
mi=0
for i in range(1,n-k+1):
  if m>b[i+k]-b[i]:
    m=b[i+k]-b[i]
    mi=i
ans=0
for i in range(n):
  if not(mi<=i<mi+k):ans+=max(0,a[i])
print(max(x,ans))