N,K = map(int,input().split())
A = list(map(int,input().split()))
L,R,C = [0],[0],[sum(A[:K])]
for i in range(N):
    L.append(L[-1]+max(A[i],0))
    R.append(R[-1]+max(A[N-i-1],0))
for i in range(N-K):
    C.append(C[-1]+A[i+K]-A[i])
ans = 0
for i in range(N-K+1):
    ans = max(ans,L[i]+C[i]+R[N-K-i],L[i]+R[N-K-i])
print(ans)