N,K = map(int,input().split())
A = list(map(int,input().split()))
B_index,W_index = 0,0
B = sum(A[:K])
W = B
hoge = B
for i in range(N-K):
    hoge += A[i+K] - A[i]
    if hoge > B:
        B = hoge
        B_index = i+1
    if hoge < W:
        W = hoge
        W_index = i+1
B_sum = 0
W_sum = 0 
for i in range(N):
    if i < B_index:
        B_sum += max(A[i],0)
    elif B_index <= i < B_index+K:
        B_sum += A[i]
    else:
        B_sum += max(A[i],0)
    if i < W_index:
        W_sum += max(A[i],0)
    elif i >= W_index+K:
        W_sum += max(A[i],0)
print(max(B_sum,W_sum))