def main():
    N, K = map(int, input().split())
    poscs = [0] * (N+1)
    A = list(map(int, input().split()))
    for i in range(N):
        poscs[i+1] = poscs[i] + max(A[i], 0)
    total = sum(A[:K])
    ans = 0
    for i in range(N-K+1):
        tmp = poscs[i] + max(total, 0) + (poscs[N] - poscs[i+K])
        ans = max(ans, tmp)
        if i+K < N:
            total -= A[i]
            total += A[i+K]
    print(ans)


if __name__ == "__main__":
    main()
