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

al, bl = [0], [0]
for a in alist:
  al.append(al[-1] + a)
  bl.append(bl[-1] + max(0, a))

al.append(al[-1])
bl.append(bl[-1])

ans = 0
for i in range(0, n - k + 2):
  bsum = bl[-1] - bl[i + k] + bl[i]
  bb = bsum + al[i + k] - al[i]
  ans = max(ans, bb, bsum)
print(ans)
