from itertools import accumulate
import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())

    C = [0] + list(accumulate(A))
    D = [0] + list(accumulate([a if a > 0 else 0 for a in A]))
    ans = -10 ** 10
    for i in range(1, N + 1 - K + 1):
        s = D[i - 1] + D[N] - D[i + K - 1]
        t = C[i + K - 1] - C[i - 1]
        s += t if t > 0 else 0
        ans = max(ans, s)
    print(ans)

if __name__ == '__main__':
    main()
