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

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



cums = [0]

cump = [0]

for a in src:

    cums.append(cums[-1] + a)

    cump.append(cump[-1] + max(0,a))



ans = 0

for i in range(N-K+1):

    tmp = cump[i]

    tmp += max(0, cums[i+K] - cums[i])

    tmp += cump[N] - cump[i+K]

    ans = max(tmp, ans)

print(ans)

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

A = list(map(int,input().split()))



cums = [0]

cums_p = [0]

for a in A:

    cums.append(cums[-1] + a)

    cums_p.append(cums_p[-1] + max(0,a))



ans = -float('inf')

for l in range(N-K+1):

    free = cums_p[l] + cums_p[-1] - cums_p[l+K]

    cont = cums[l+K] - cums[l]

    ans = max(ans, free, free+cont)

print(ans)
N, K = list(map(int, input().split()))
src = list(map(int, input().split()))
cums = [0]
cump = [0]
for a in src:
    cums.append(cums[-1] + a)
    cump.append(cump[-1] + max(0, a))
ans = 0
for i in range(N - K + 1):
    tmp = cump[i]
    tmp += max(0, cums[i + K] - cums[i])
    tmp += cump[N] - cump[i + K]
    ans = max(tmp, ans)
print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
cums = [0]
cums_p = [0]
for a in A:
    cums.append(cums[-1] + a)
    cums_p.append(cums_p[-1] + max(0, a))
ans = -float("inf")
for l in range(N - K + 1):
    free = cums_p[l] + cums_p[-1] - cums_p[l + K]
    cont = cums[l + K] - cums[l]
    ans = max(ans, free, free + cont)
print(ans)

-src = list(map(int, input().split())) +A = list(map(int, input().split())) -cump = [0] -for a in src: +cums_p = [0] +for a in A: -    cump.append(cump[-1] + max(0, a)) -ans = 0 -for i in range(N - K + 1): -    tmp = cump[i] -    tmp += max(0, cums[i + K] - cums[i]) -    tmp += cump[N] - cump[i + K] -    ans = max(tmp, ans) +    cums_p.append(cums_p[-1] + max(0, a)) +ans = -float("inf") +for l in range(N - K + 1): +    free = cums_p[l] + cums_p[-1] - cums_p[l + K] +    cont = cums[l + K] - cums[l] +    ans = max(ans, free, free + cont)