N,K = map(int,input().split())
src = list(map(int,input().split()))

cums = [0]
p_cums = [0]
for a in src:
    cums.append(cums[-1] + a)
    p_cums.append(p_cums[-1] + max(0,a))

ans = -float('inf')
for l in range(N-K+1):
    r = l + K
    tmp = p_cums[l]
    tmp += max(0, cums[r] - cums[l])
    tmp += p_cums[-1] - p_cums[r]
    ans = max(ans, tmp)
print(ans)
