###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N, K = mi()
As = list(mi())

c_m = [] # cumsum_minus
c_p = [] # cumsum_plus

#番兵的に0を追加しておく
c_m.append(0)
c_p.append(0)

for a in As:
  if a <= 0:
    c_m.append(c_m[-1] + a)
    c_p.append(c_p[-1])
  else:
    c_p.append(c_p[-1] + a)
    c_m.append(c_m[-1])


ans = -INF
for i in range(N-K+1): #0 ~ N-K までループ
  # [i, i+K) を all or nothing にする
  tmpans = 0
  tmpans += max(0, c_m[i+K] - c_m[i] + c_p[i+K] - c_p[i])
  tmpans += c_p[i] + c_p[N] - c_p[i+K]#左端からi-1までの累積和([i-1+1]) + i+kから右端までの累積和 [i+k, N)
  ans = max(ans, tmpans)

print(ans)




