N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]
C=[0]
for i in range(N):
  B.append(B[i]+max(0,A[i]))
  C.append(C[i]-min(0,A[i]))
P=10**20
for i in range(N-K+1):
  P=min(P,B[i+K]-B[i],C[i+K]-C[i])
print(B[N]-P)