from itertools import accumulate

N, K = map(int, input().split())
*A, = map(int, input().split())
acc = (0,) + tuple(accumulate(A))
acc_p = (0,) + tuple(accumulate(x if x > 0 else 0 for x in A))

ret = -10 ** 14
for i in range(N - (K - 1)):
    sum_ = acc[i + K] - acc[i]
    ret = max(ret, (acc_p[-1] - acc_p[i + K]) + acc_p[i] + (sum_ if sum_ > 0 else 0))

print(ret)

# 連続する長さKの区間を黒/白で塗る
# 残りを自由に塗る
