# 解説AC
N,K = map(int, input().split())
A = [int(i) for i in input().split()]

# 累積和
S1 = [0] * (N + 1)
# 正のみの累積和
S2 = [0] * (N + 1)
for i in range(N):
    S1[i+1] = S1[i] + A[i]
    S2[i+1] = S2[i] + (A[i] if A[i] >= 0 else 0)

ans = -float("inf")
for i in range(N - K + 1):
    left, right = i, i + K
    
    tmp = S2[left] - S2[0] # 左側
    tmp += max(0, S1[right] - S1[left]) # 連続部分列
    tmp += S2[N] - S2[right] # 右側

    ans = max(ans, tmp)

print(ans)