N, K = map(int,input().split())
L = list(map(int,input().split()))
M = []
for e in L:
    M.append(max(0,e))

S = [0]*(N+1)
T = [0]*(N+1)
for k in range(N):
    S[k+1] = L[k]+S[k]
    T[k+1] = M[k]+T[k]
ans = 0
for k in range(N-K+1):
    ans = max(ans, T[k] + max(0,S[k+K]-S[k]) + T[N]-T[k+K])
print(ans)
