n, k = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A[:k])
T = 0
for i in range(k, n):
  T += max(0, A[i])
ans = max(0, S) + T
for i in range(k, n):
  S -= A[i-k]
  S += A[i]
  T += max(0, A[i-k])
  T -= max(0, A[i])
  ans = max(ans, max(0, S)+T)
print(ans)