fun main() {
    val (n, k) = readInts()
    val prefix = MutableList(n + 1) { 0L }
    val suffix = MutableList(n + 1) { 0L }

    (0..n).forEach { num ->
        prefix[num] = num + if (num > 0) prefix[num - 1] else 0
        suffix[n - num] = n - num + if (num > 0) suffix[n - num + 1] else 0
    }
    val mod = 1000000007L
    var ans = 0L
    for (i in k..(n + 1)) ans = (ans + suffix[n - i + 1] - prefix[i - 1] + 1) % mod
    println(ans)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
