val MOD = 1000000007L

fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }

    var max = (n downTo (n-k)+1).sum()
    var min = (0..k-1).sum()

    var ans = 0L

    for (i in k..n+1) {
        ans += max - min + 1
        ans %= MOD

        min += i
        max += n-i
    }

    println(ans)
}