N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = [0] * N
max_a = 0
for i in range(N):
    if A[i] > 0:
        B[i] = A[i]
    if i > 0:
        B[i] += B[i - 1]

for i in range(1, N):
    A[i] += A[i - 1]

ans = -1e12
for i in range(N - K+1):
    x = A[i + K - 1] - (A[i - 1] if i > 0 else 0)
    y = B[-1] - (B[i + K - 1] - (B[i - 1] if i > 0 else 0))
    ans = max(y,y+x,ans)
print(ans)