import java.io.PrintWriter

//private val inp = java.io.File("in")
private val inp = System.`in`
private val reader = inp.bufferedReader()
private val wr = PrintWriter(System.out.bufferedWriter())

private fun readLn(): String = reader.readLine()
private fun readInt(): Int = readLn().toInt()
private fun readStrs(): List<String> = readLn().split(" ")
private fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()
private fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()

fun main() {
    val (n, k) = readInts()
    val pref = LongArray(n + 2)
    val mod = 1e9 + 7
    for (i in 1..n + 1) {
        pref[i] += pref[i - 1] + i - 1
    }

    var ans = 0L
    for (i in k..n + 1) {
        val minSum = pref[i]
        val maxSum = pref[n + 1] - pref[n + 1 - i]
        ans += maxSum - minSum + 1
        ans = (ans % mod).toLong()
    }

    println(ans)
}
