fun main() {
    println(solve())
}

val solve: () -> Any = {
    val (N, K) = readIntList()
    val list = (0L..N).toList()
    var first = list.takeLast(K-1).sum()
    var last = list.take(K-1).sum()
    var ans = 0L
    for (n in K .. N + 1) {
        first += list[N-n+1]
        last += list[n-1]
        ans += first - (last - 1)
        ans %= 1_000_000_000L + 7
    }
    ans
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)