fun main(args: Array<String>) {
    var (n, k) = readLine()!!.split(" ").map{it.toInt()}
    var nmin = 0L
    var nmax = 0L
    for (i in 0..k-2) {
        nmin += i
        nmax += n-i
    }
    var ans = 0L
    for (i in k-1..n) {
        nmin += i
        nmax += n-i
        ans += nmax - nmin + 1
        ans %= 1_000_000_000 + 7
    }
    println(ans)
}
