N, K = map(int, input().split())
A = [int(x) for x in input().split()]

S0 = 0
S1 = sum(A[i] for i in range(K))
S2 = sum(A[i] for i in range(K, N) if A[i] > 0)
A.append(0)

ans = sum(A)
for i in range(N-K+1):
#     print(i, i+K, S0, S1, S2)
    ans = max(ans, S0 + max(S1, 0) + S2)
    if A[i] > 0:
        S0 += A[i]
    if A[i+K] > 0:
        S2 -= A[i+K]
    S1 = S1 - A[i] + A[i+K]
print(ans)