class cumulative_sum:
    def __init__(self,A):
        N = len(A)
        self.S = [0]*(N+1)
        for i in range(N):
            self.S[i+1] = self.S[i] + A[i]
    def get(self,i,j=None):
        if j==None:j=len(self.S)-1
        if j<=i:return 0
        return self.S[j]-self.S[i]

N,K = map(int,input().split())
*A, = map(int,input().split())
B = [max(0,a) for a in A]
SA = cumulative_sum(A)
SB = cumulative_sum(B)
ans = 0
for i in range(N-K+1):
    tmp = max(0,SA.get(i,i+K)) + SB.get(0,i) + SB.get(i+K)
    ans = max(ans,tmp)
print(ans)