n,k = map(int,input().split())
lis = list(map(int,input().split()))
num = 0
ans = 0
for i in range(n):
  num += max(0,lis[i])
li = [0 for i in range(n-k+1)]
for i in range(n-k+1):
  cou = 0
  co = 0
  for nu in lis[i:i+k+1]:
    if nu >= 0:
      cou += nu
    else:
      co -= nu
  if cou >= co:ans = max(ans,num-co)
  else:ans = max(ans,num-cou)
  
print(ans)