import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    A = [int(input_raw[i]) for i in range(N)]

    sumA = [0 for i in range(N + 1)]
    sumAplus = [0 for i in range(N + 1)]
    for i in range(N):
        sumA[i + 1] = sumA[i] + A[i]
        sumAplus[i + 1] = sumAplus[i] + max(A[i], 0)

    max_score_b = 0
    max_score_w = 0
    for i in range(1, N - K + 2):
        score_b = (sumAplus[i - 1] - sumAplus[0]) + (sumA[i + K - 1] - sumA[i - 1]) + (sumAplus[N] - sumAplus[i + K - 1])
        max_score_b = max(max_score_b, score_b)
        score_w = (sumAplus[i - 1] - sumAplus[0]) + (sumAplus[N] - sumAplus[i + K - 1])
        max_score_w = max(max_score_w, score_w)
    print max(max_score_b, max_score_w)


if __name__ == '__main__':
    main()
