const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const [N, K] = input.split(' ').map(Number)

    let count = 0;
    let s = 0
    let e = 0
    for (let j = 0; j < K; j++) {
        s += j
    }
    for (let j = N + 1 - K; j <= N; j++) {
        e += j
    }
    count += e - s + 1
    for (let k = K + 1; k <= N +  1; k++) {
        s += (k - 1)
        e += N + 1 - k
        count += e - s + 1
    }
    console.log(count % 1000000007)

})(input)
