n, k = map(int, input().split())
alst = list(map(int, input().split()))

total_1 = 0
total_2 = 0
for i in range(k):
    total_1 += min(0, alst[i])
    total_2 += max(0, alst[i])
t_max = total_1
t_min = total_2
max_pos = 0
min_pos = 0
for i in range(n - k):
    total_1 += min(alst[i + k], 0) - min(alst[i], 0)
    total_2 += max(alst[i + k], 0) - max(alst[i], 0)
    if total_1 > t_max:
        t_max = total_1
        max_pos = i + 1
    if total_2 < t_min:
        t_min = total_2
        min_pos = i + 1
ans = 0
ans2 = 0

for i, num in enumerate(alst):
    if max_pos <= i < max_pos + k:
        ans += num
    else:
        ans += max(num, 0)
        
    if min_pos <= i < min_pos + k:
        pass
    else:
        ans2 += max(num, 0)

print(max(ans, ans2))