
fun main() {
    // 4C2 +    4C1
    val mod = (1e9+7).toLong()
    fun modInv(d:Long, p:Int) : Long {
        if(p == 0) return 1L
        if(p == 1) return d
        var v = modInv(d, p / 2)
        v = (v * v) % mod
        if(p % 2 != 0) {
            v *= d
            v %= mod
        }
        return v
    }

    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val acc = LongArray(n + 1){0L}

    for(i in 1..n) {
        acc[i] = (acc[i - 1] + i) % mod
    }

    val facto = LongArray(n+2)

    fun comb(n:Int, k:Int): Long {
        var r = (facto[k] * facto[n - k]) % mod
        r = facto[n] * modInv(r, (mod - 2).toInt()) % mod
        return r
    }

    facto[0] = 1
    for(i in 1..n + 1) {
        facto[i] = (facto[i-1] * i) % mod
    }
    // 0 1 2 3
    // 0 1 3 6
    var ans = 0L
    for(r in k .. n+1) {
        //첫항
        val from = acc[r - 1]
        val prev = if(n - r < 0) 0 else acc[n-r]
        val to = (acc[n] - prev + mod) % mod
        val d = (to - from + 1 + mod) % mod
        ans += d
        ans %= mod
    }

    println(ans)
    //N+1 C K ... N+1 C K + 1, ... N + 1 C N + 1






}