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

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

white = [0] * (N + 1)
black = [0] * (N + 1)
for i, d in enumerate(a):
  if d < 0:
    white[i + 1] += d
  else:
    black[i + 1] += d
  white[i + 1] += white[i]
  black[i + 1] += black[i]

score = 0
for i in range(N - K + 1):
  score = max(black[N] + white[i + K] - white[i], black[N] - black[i + K] + black[i], score)

print(score)