import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,K = LI()
    a = LI()

    ac = [0]
    ap = [0]
    for x in a:
        ac.append(ac[-1]+x)
        ap.append(ap[-1]+(x if x>0 else 0))

    ans = -INF
    for i in range(N-K+1):
        bw = max(ac[i+K] - ac[i],0)
        l = ap[i]
        r = ap[N] - ap[i+K]
        ans = max(ans,bw+l+r)
    print(ans)

if __name__ == '__main__':
    main()