
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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

S = [0] * (N+1)
for i in range(1, N+1):
    S[i] = S[i-1] + A[i-1]

# 正の数限定の累積和
O = [0] * (N+1)
for i in range(1, N+1):
    x = max(0, A[i-1])
    O[i] = O[i-1] + x

#print(S)

# 区間を白/黒、区間の外を白/黒で比較
ans = 0
for i in range(N-K+1):
    l = i
    r = i+K-1

    # 区間
    sum_in = S[r+1] - S[l]

    # 左区間
    if i == 0:
        sum_left = 0
    else:
        sum_left = O[l]-O[0]

    # 右区間
    if r+1 < N:
        sum_right = O[N]-O[r+1]
    else:
        sum_right = 0

    # 全部黒
    tmp = 0
    tmp = max(tmp, sum_in+sum_left+sum_right)

    # 区間だけ黒
    tmp = max(tmp, sum_in)

    # 区間だけ白
    tmp = max(tmp, sum_left+sum_right)

    ans = max(ans, tmp)

#    print(tmp, sum_in, sum_left, sum_right, l, r)


print(ans)