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

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

total=[0]*(n+1)

asum=[0]*(n+1)

for i in range(n):

    asum[i+1]=asum[i]+a[i]

    if a[i]>0:

        total[i+1]=total[i]+a[i]

    else:

        total[i+1]=total[i]

ans=0

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

    tmp=asum[i+k]-asum[i]

    ans=max(ans,tmp+total[i]+total[n]-total[i+k],total[i]+total[n]-total[i+k])



print(ans)

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

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

s1=[0]*n

s1[0]=a[0]

s2=[0]*n

if a[0]>0:

    s2[0]=a[0]

for i in range(1,n):

    s1[i]+=s1[i-1]+a[i]

    s2[i]+=s2[i-1]

    if a[i]>0:

        s2[i]+=a[i]

ans=-float("inf")

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

    if i==0:

        tmp1=s1[i+k-1]

        tmp2=s2[n-1]-s2[i+k-1]

    else:

        tmp1=s1[i+k-1]-s1[i-1]

        tmp2=s2[n-1]-(s2[i+k-1]-s2[i-1])

    ans=max(ans,tmp1+tmp2,tmp2)

print(ans)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
total = [0] * (n + 1)
asum = [0] * (n + 1)
for i in range(n):
    asum[i + 1] = asum[i] + a[i]
    if a[i] > 0:
        total[i + 1] = total[i] + a[i]
    else:
        total[i + 1] = total[i]
ans = 0
for i in range(n - k + 1):
    tmp = asum[i + k] - asum[i]
    ans = max(
        ans,
        tmp + total[i] + total[n] - total[i + k],
        total[i] + total[n] - total[i + k],
    )
print(ans)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
s1 = [0] * n
s1[0] = a[0]
s2 = [0] * n
if a[0] > 0:
    s2[0] = a[0]
for i in range(1, n):
    s1[i] += s1[i - 1] + a[i]
    s2[i] += s2[i - 1]
    if a[i] > 0:
        s2[i] += a[i]
ans = -float("inf")
for i in range(n - k + 1):
    if i == 0:
        tmp1 = s1[i + k - 1]
        tmp2 = s2[n - 1] - s2[i + k - 1]
    else:
        tmp1 = s1[i + k - 1] - s1[i - 1]
        tmp2 = s2[n - 1] - (s2[i + k - 1] - s2[i - 1])
    ans = max(ans, tmp1 + tmp2, tmp2)
print(ans)

-total = [0] * (n + 1) -asum = [0] * (n + 1) -for i in range(n): -    asum[i + 1] = asum[i] + a[i] +s1 = [0] * n +s1[0] = a[0] +s2 = [0] * n +if a[0] > 0: +    s2[0] = a[0] +for i in range(1, n): +    s1[i] += s1[i - 1] + a[i] +    s2[i] += s2[i - 1] -        total[i + 1] = total[i] + a[i] +        s2[i] += a[i] +ans = -float("inf") +for i in range(n - k + 1): +    if i == 0: +        tmp1 = s1[i + k - 1] +        tmp2 = s2[n - 1] - s2[i + k - 1] -        total[i + 1] = total[i] -ans = 0 -for i in range(n - k + 1): -    tmp = asum[i + k] - asum[i] -    ans = max( -        ans, -        tmp + total[i] + total[n] - total[i + k], -        total[i] + total[n] - total[i + k], -    ) +        tmp1 = s1[i + k - 1] - s1[i - 1] +        tmp2 = s2[n - 1] - (s2[i + k - 1] - s2[i - 1]) +    ans = max(ans, tmp1 + tmp2, tmp2)