N, K = map(int, input().split())
A = [int(x) for x in input().split()]
P = [a if a > 0 else 0 for a in A]
M = [a if a < 0 else 0 for a in A]
W = [sum(P[:K])] * (N - K + 1)
B = [sum(M[:K])] * (N - K + 1)
for i in range(N - K):
  W[i + 1] = W[i] + P[i + K] - P[i]
  B[i + 1] = B[i] + M[i + K] - M[i]
print(sum(P) - min(min(W), -max(B)))