package main

import (
	"fmt"
	"math"
)

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	s := make([]int64, n+1)
	w := make([]int64, n+1)
	for i := 0; i < n; i++ {
		s[i+1] = s[i] + int64(a[i])
		w[i+1] = w[i] + int64(max(a[i], 0))
	}
	ans := int64(math.MinInt64)
	for i := 0; i <= n-k; i++ {
		x := w[n] - (w[i+k] - w[i])
		x += max64(s[i+k]-s[i], 0)
		ans = max64(ans, x)
	}
	fmt.Println(ans)
}
