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

black = sum(a[:k])
white = 0

for i in range(k,n):
    if a[i]>0:
        white += a[i]
black += white

b = [black]
w = [white]

for i in range(n-k):
    if a[i]>0:
        white += a[i]
    else:
        black -= a[i]
    if a[i+k] > 0:
        white -= a[i+k]
    else:
        black += a[i+k]
    b.append(black)
    w.append(white)

print(max(max(b),max(w)))

