import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    sm = 0
    for i in a:
        if i > 0:
            sm += i
    ws = 0
    bs = 0
    for i in a[:k:]:
        if i > 0:
            ws += i
        else:
            bs -= i
    ms = min(ws,bs)
    for i in range(n-k):
        ai = a[i]
        af = a[i+k]
        if ai > 0:
            ws -= ai
        else:
            bs += ai
        if af > 0:
            ws += af
        else:
            bs -= af
        if ms > ws:
            ms = ws
        elif ms > bs:
            ms = bs
    print(sm-ms)



    return

if __name__ == '__main__':
    main()
