from itertools import accumulate

def main():
    N, K, *A = map(int, open(0).read().split())

    M = [a if a < 0 else 0 for a in A]
    P = [a if a > 0 else 0 for a in A]

    MA = [0] + list(accumulate(M))
    PA = [0] + list(accumulate(P))

    minus = max(q - p for p, q in zip(MA, MA[K:]))
    plus = min(q - p for p, q in zip(PA, PA[K:]))

    print(sum(P) + max(minus, -plus))


if __name__ == '__main__':
    main()
