const val mod = 1e9.toLong()+7L
class MInt(_x: Long){
    var x : Long = (_x%mod+mod)% mod
    public final operator fun unaryMinus(): MInt = MInt(-x)
    public final operator fun plus(a : MInt) = MInt(x+a.x)
    public final operator fun minus(a : MInt) = MInt(x-a.x)
    public final operator fun times(a : MInt) = MInt(x*a.x)
    public final operator fun div(a : MInt) = this*a.invMod()

    public final fun pow(t : Long) : MInt {
        if (t == 0L) return MInt(1)
        var a = pow(t shr 1)
        a *= a
        if (t and 1L == 1L) a *= this
        return a
    }
    private final fun extGcd(a: Long, b : Long) : Triple<Long, Long, Long>{
        if(b == 0L) return Triple(1, 0, a)
        val q = a / b
        val (_x,y, g) = extGcd(b, a-q*b)
        val z = _x - q*y
        return Triple(y, z, g)
    }
    public final fun invMod() : MInt {
        var (_x,y,g) = extGcd(x,mod)
        _x %= mod
        if(_x<mod) _x += mod
        return MInt(_x)
    }
}

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    var sum = MInt(0)
    for(i in k..(n+1)){
        val sumN = MInt(n) * MInt(n+1) / MInt(2L)
        val sumNK = MInt(n-i) * MInt(n-i+1) / MInt(2L)
        val sumK1 = MInt(i-1) * MInt(i) / MInt(2L)
        val inSum = sumN - sumNK - sumK1 + MInt(1)
        sum += inSum
    }
    println(sum.x)
}