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

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

psum = 0

for i in a:
    if i > 0:
        psum += i


nsum = 0

for i in range(K):
    nsum += a[i]

    if a[i] > 0:
        psum -= a[i]

ans = max( psum + nsum , psum )

for i in range(N - K):

    nsum -= a[i]
    if a[i] > 0:
        psum += a[i]

    nsum += a[K+i]
    if a[K+i] > 0:
        psum -= a[K+i]

    ans = max( ans , psum + nsum , psum )

print (ans)

    
