N, K = map(int, input().split())
A = list(map(int, input().split()))

lst = [0]
lst_append = lst.append
for a in A:
    lst_append(lst[-1] + max(0, a))

tmp = sum(A[:K])
ans = lst[N] - lst[K] + max(0, tmp)
for i in range(K, N):
    tmp += A[i] - A[i - K]
    next_ = (lst[N] - lst[i + 1]) + max(0, tmp) + lst[i - K + 1] - lst[0]

    ans = max(ans, next_)

print (ans)