import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def main():
    n,k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    r = 0
    for c in a:
        if c > 0:
            r += c
    ps = 0
    ms = 0
    for c in a[:k]:
        if c > 0:
            ps += c
        else:
            ms -= c
    mi = min(ps,ms)
    for i in range(k,n):
        kc = a[i-k]
        if kc > 0:
            ps -= kc
        else:
            ms += kc
        c = a[i]
        if c > 0:
            ps += c
        else:
            ms -= c
        mi = min(mi,ps,ms)
    return r-mi


print(main())
