let mod = 1_000_000_007

let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let K = input[1]

func sum(_ first: Int, _ last: Int, _ count: Int) -> Int {
    (first + last) * count / 2
}

var result = 0
for i in K ... N + 1 {
    let min = sum(0, i - 1, i)
    let max = sum(N - i + 1, N, i)
    result += max - min + 1
    result %= mod
}

print(result)
