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


class CumSum(val A: List<Long>) {
    private var csum: LongArray = LongArray(A.size + 1)
    init {
        for (i in 1..A.size) {
            this.csum[i] = this.csum[i-1] + A[i-1]
        }
    }
    fun sum(L: Int, R: Int): Long {
        val r = min(R, A.size);
        val l = max(L, 0)
        if (l >= r) return 0
        return this.csum[r] - this.csum[l];
    }
}


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 plSum = CumSum(plus)
    val miSum = CumSum(minus)

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

    return res
}


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

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

    println(ans)
}
