from itertools import accumulate as acc
N, K, *a = map(int, open(0).read().split())
*b, = map(lambda x: max(x, 0), a)
*Sa, = acc([0] + a)
*Sb, = acc([0] + b)
print(max(Sb[i] + max(0,Sa[i+K]-Sa[i]) + Sb[N]-Sb[i+K] for i in range(N-K+1)))