from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect
 
def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N, K = reads()
a = reads()

ppsum = [0] * (N+1)
psum = [0] * (N+1)

for i in range(N):
  ppsum[i+1] = ppsum[i] + max(0, a[i])
  psum[i+1] = psum[i] + a[i]

ansb = max(ppsum[i] + psum[i+K] - psum[i] + ppsum[N] - ppsum[i+K] for i in range(N-K+1))
answ = max(ppsum[i] + ppsum[N] - ppsum[i+K] for i in range(N-K+1))

print(max(ansb, answ))