import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import accumulate
    n, k = map(int, readline().split())
    a = list(map(int, readline().split()))
    b = [0] * (n + 1)
    c = [0] * (n + 1)

    for i, x in enumerate(a, 1):
        b[i] = b[i - 1] + max(x, 0)
        c[i] = c[i - 1] + x

    ans = 0
    for i in range(n - k + 1):
        score = b[i] + max(0, c[i + k] - c[i]) + (b[n] - b[i + k])
        ans = max(ans, score)

    print(ans)


if __name__ == '__main__':
    main()
