n,k = list(map(int, input().split()))

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

al = [0]*(n+1)

pl = [0]*(n+1)

ans = -10**10

for i in range(n):

  al[i+1] = al[i] + a[i]

  pl[i+1] = pl[i] + max(0,a[i])

for i in range(n-k+1):

  l,r = i,i+k-1

  cur = max(0,al[r+1]-al[l]) + pl[l] + pl[-1] - pl[r+1]

  if cur > ans:

    ans = cur

print(ans)
n,k = list(map(int,input().split()))

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

al = [0]*(n+1)

pl = [0]*(n+1)

ans = 0

for i in range(n):

  al[i+1] = al[i] + a[i]

  pl[i+1] = pl[i]

  if a[i] > 0: pl[i+1] += a[i]

for r in range(k-1,n):

  l = r-k+1

  cur = pl[l] + max(0, al[r+1] - al[l]) + pl[n] - pl[r+1]

  if ans < cur: ans = cur

print(ans)
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
al = [0] * (n + 1)
pl = [0] * (n + 1)
ans = -(10**10)
for i in range(n):
    al[i + 1] = al[i] + a[i]
    pl[i + 1] = pl[i] + max(0, a[i])
for i in range(n - k + 1):
    l, r = i, i + k - 1
    cur = max(0, al[r + 1] - al[l]) + pl[l] + pl[-1] - pl[r + 1]
    if cur > ans:
        ans = cur
print(ans)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
al = [0] * (n + 1)
pl = [0] * (n + 1)
ans = 0
for i in range(n):
    al[i + 1] = al[i] + a[i]
    pl[i + 1] = pl[i]
    if a[i] > 0:
        pl[i + 1] += a[i]
for r in range(k - 1, n):
    l = r - k + 1
    cur = pl[l] + max(0, al[r + 1] - al[l]) + pl[n] - pl[r + 1]
    if ans < cur:
        ans = cur
print(ans)

-ans = -(10**10) +ans = 0 -    pl[i + 1] = pl[i] + max(0, a[i]) -for i in range(n - k + 1): -    l, r = i, i + k - 1 -    cur = max(0, al[r + 1] - al[l]) + pl[l] + pl[-1] - pl[r + 1] -    if cur > ans: +    pl[i + 1] = pl[i] +    if a[i] > 0: +        pl[i + 1] += a[i] +for r in range(k - 1, n): +    l = r - k + 1 +    cur = pl[l] + max(0, al[r + 1] - al[l]) + pl[n] - pl[r + 1] +    if ans < cur: