#AGc008B

n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
w=[0 for i in xrange(n+1)]
b=[0 for i in xrange(n+1)]

for i in xrange(n):
 w[i+1]=w[i]+a[i]
 b[i+1]=b[i]+max(0,a[i])

res=0
for i in xrange(n-k+1):
 x=(b[i]-b[0])+(b[n]-b[i+k])
 y=x+(w[i+k]-w[i])
 res=max(res,x,y)

print res
