N, K = map(int, input().split())
As = list(map(int, input().split())) + [0]

sumRest = sum([A for A in As[K:] if A > 0])
sumPlus = sumMinus = 0
for A in As[:K]:
    if A > 0:
        sumPlus += A
    else:
        sumMinus += A

ans = 0
for i in range(N - K + 1):
    score = sumRest + max(sumPlus + sumMinus, 0)
    ans = max(ans, score)

    if As[i + K] > 0:
        sumRest -= As[i + K]
        sumPlus += As[i + K]
    else:
        sumMinus += As[i + K]

    if As[i] > 0:
        sumRest += As[i]
        sumPlus -= As[i]
    else:
        sumMinus -= As[i]

print(ans)
