n, k = map(int, raw_input().split())
A = map(int, raw_input().split())
B = [0]*(n+1)
C = [0]*(n+1)
for i in xrange(n):
    B[i+1] = B[i] + A[i]
    C[i+1] = C[i] + A[i]*(A[i] > 0)
print max(C[i] + C[n]-C[i+k] + max(B[i+k]-B[i], 0) for i in xrange(n-k+1))