N,K = map(int,input().split())
*A, = map(int,input().split())
S = [0]*(N+1)
Sp = [0]*(N+1)
for i,a in enumerate(A,1):
    S[i] = S[i-1]+a
    Sp[i] = Sp[i-1] + max(0,a)
ans = 0
for i in range(N-K+1):
    ans = max(ans,max(0,S[K+i]-S[i]) + Sp[-1] - (Sp[K+i]-Sp[i]))
print(ans)