N, K = map(int,input().split())
a = list(map(int,input().split()))

white_start, black_start = 0, 0
white_sum, black_sum = 0, 0#K区間を白、黒にしたときの"損失"
for i in range(K):
  white_sum += max(-a[i],0)
  black_sum += max(a[i],0)
curr_white = white_sum
curr_black = black_sum

for i in range(N-K):
  curr_white += max(-a[i+K],0) - max(-a[i],0)
  curr_black += max(+a[i+K],0) - max(+a[i],0)
  if curr_white < white_sum :
    white_sum = curr_white
    white_start = i+1
  if curr_black < black_sum :
    black_sum = curr_black
    black_start = i+1
ans = 0
if white_sum < black_sum:#白塗りのほうがいい
  for i in range(N):
    if i < white_start or i >= white_start+K:
      ans += max(a[i],0)
    else: ans+=a[i]
  print(ans)
else:
  for i in range(N):
    if i < black_start or i >= black_start+K:
      ans += max(a[i],0)
  print(ans)