import java.util.*
import java.math.*
import java.lang.Math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }
private val MOD = 1e9.toLong()+7
private val INF = Int.MAX_VALUE/2
private val LINF = Long.MAX_VALUE/2


fun solveB(N: Int, K: Int, A: List<Long>): Long {
    val plus = A.map {if (it >= 0) it else 0}
    val minus = A.map { if (it < 0) it else 0 }

    val Max = plus.sum()
    var res = 0L
    for (left in 0 .. N-K) {
            res = max(res, Max - plus.slice(left until left+K).sum())
            res = max(res, Max + minus.slice(left until left+K).sum())
    }

    return res
}


fun main(args: Array<String>) {
    val (N,K) = readListInt()
    var A = readListLong()

    val ans = solveB(N, K, A.toList())

    println(ans)
}
