N, K = map(int, input().split())
a = list(map(int, input().split()))
mae = 0
naka = sum(a[:K])
usiro = 0
for i in range(K, N):
    if a[i]>0:
        usiro+=a[i]
ans = max(mae+naka+usiro, mae+usiro)
for i in range(N-K):
    naka+=a[i+K]-a[i]
    if a[i]>0:
        mae+=a[i]
    if a[i+K]>0:
        usiro-=a[i+K]
    ans = max(ans, mae+naka+usiro, mae+usiro)
print(ans)