@ExperimentalStdlibApi
fun main(args: Array<String>) = abc163d()

@ExperimentalStdlibApi
fun abc163d() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }

    val list = (0L..n).toList()
    val cSum = list.scan(0L, Long::plus)

    val map = (k..n + 1).map { (cSum.last() - cSum[cSum.lastIndex - it]) - cSum[it] + 1 }
    val answer = map.fold(0L) { acc, l -> (acc + l) % MOD }

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()
