package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  var n,k int = NextInts()
  var a []int = NextIntArray()
  var r []int64 = make([]int64,n+1)
  for i:=n-1;i>-1;i-- {
    r[i] = r[i+1]
    if a[i] > 0 { r[i] += int64(a[i]) }
  }
  var s int64
  var m int64 = r[k]
  for i:=0;i<n-k;i++ {
    if a[i] > 0 { s += int64(a[i]) }
    if m < s+r[i+k+1] { m = s+r[i+k] }
  }
  fmt.Println(m)
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInts() (int,int) {
  var s []string = strings.Split(NextLine()," ")
  n,_ := strconv.Atoi(s[0])
  k,_ := strconv.Atoi(s[1])
  return n,k
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var a []int = make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}