N, K = map(int, input().split())
a = list(map(int, input().split()))
sa = [0]
for i in range(N):
    sa.append(sa[-1] + a[i])

sb = [0]
for i in range(N):
    sb.append(sb[-1] + max(0, a[i]))


num = 0
for i in range(N - K + 1):
    num = max(num, sb[i] + max(0, sa[i + K] - sa[i]) + sb[N] - sb[i + K])

print(num)

