import java.io.PrintWriter

fun main() {
    val pw = PrintWriter(System.out)

    val (n, k) = readInputLine().split(" ").map { it.toLong() }

    val mod = 1000000007L

    var ans = 0L

    for (i in LongRange(k, n + 1L)) {
        val l = (i - 1L) * i / 2L
        val r = n * (n + 1L) / 2L - (n - i) * (n - i + 1L) / 2L

        ans = (ans + r - l + 1L) % mod
    }

    pw.println(ans)

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}
