from sys import stdin
def main():
    n, k = map(int, stdin.readline().split())
    a = map(int, stdin.readline().split())
    s = [0] * (n + 1)
    t = [0] * (n + 1)
    for i, x in enumerate(a):
        s[i+1] = s[i] + x
        t[i+1] = t[i] + (x if x > 0 else 0)
    ans = 0
    for i in xrange(n - k + 1):
        v = s[i+k] - s[i]
        if v < 0:
            v = 0
        v += t[i] + t[n] - t[i+k]
        if ans < v:
            ans = v
    print ans
main()
