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

ans = sum([a for a in A if a > 0])
B = [a if a <= 0 else 0 for a in A]

s = sum(B[:K])
s_max = s
for i in range(N-K):
  s += B[i+K] - B[i]
  s_max = max(s_max, s)

B = [a if a > 0 else 0 for a in A]
s = sum(B[:K])
s_min = s
for i in range(N-K):
  s += B[i+K] - B[i]
  s_min = min(s_min, s)

print(max(ans+s_max, ans-s_min))