import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    L = [0] * (N + 1)
    for i in range(N):
        L[i + 1] = L[i]
        if A[i] > 0:
            L[i + 1] += A[i]
    
    R = [0] * (N + 1)
    for i in range(N - 1,-1,-1):
        R[i] = R[i + 1]
        if A[i] > 0:
            R[i] += A[i]
    
    ans = 0
    range_sum = sum(A[:K])
    for i in range(K,N + 1):
        ret = max(L[i - K] + range_sum + R[i],L[i - K] + R[i])
        ans = max(ans,ret)
        range_sum -= A[i - K]
        if i < N:
            range_sum += A[i]
    print(ans)
if __name__ == '__main__':
    main()