N,K=map(int,input().split())
A=list(map(int,input().split()))
p=[0]*(N+1)
m=[0]*(N+1)
for i in range(N):
    p[i+1]=p[i]
    m[i+1]=m[i]
    if A[i]>0:
        p[i+1]+=A[i]
    elif A[i]<0:
        m[i+1]-=A[i]
a=10**15
for i in range(N-K+1):
    a=min(a,p[i+K]-p[i],m[i+K]-m[i])
print(p[N]-a)