from itertools import accumulate

N, K = map(int, input().split())
*A, = map(int, input().split())
A_pos = list(map(lambda x: max(x, 0), A))
A_pos_cumsum = [0] + list(accumulate(A_pos))
ans = -float('inf')
S = sum(A[0: K])
for i in range(N - K + 1):
    ans = max(ans, max(S, 0) + A_pos_cumsum[i] + (A_pos_cumsum[-1] - A_pos_cumsum[i+K]))
    S = S - A[i] + A[i+K] if i < N - K else 0
print(ans)