
N,K = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))

left = max_left =  0
right = max_right=  K
temp = ma = sum(As[0:right])

anss = [0]
for i in range(N - K ): # K 個を黒で塗る
    left += 1
    right += 1
    temp =  temp - As[left -1 ] + As[right -1]
    if ma < temp:
        max_left = left
        max_right = right
        ma = temp

for i in range(N):
    if not (max_left <= i <= max_right):
        if As[i] > 0:
            ma += As[i]


anss.append(ma)

left = min_left =  0
right = min_right=  K
temp = mi = sum(As[0:right ])
for i in range(N - K - 1):  # K 個を白で塗る
    left += 1
    right += 1
    temp = mi - As[left - 1] + As[right - 1]
    if mi > temp:
        max_left = left
        max_right = right
        mi = temp
temp = 0
for i in range(N):
    if not (max_left <= i <= max_right):
        if As[i] > 0:
            temp += As[i]

anss.append(ma)

print(max(anss))
