// Sum of Large Numbers

func rangeSum(_ start: Int, _ end: Int) -> Int {
    let count = end - start + 1
    return (start + end) * count / 2
}

func combi(n: Int, k: Int) -> Int{
    let min = rangeSum(0, k-1)
    let max = rangeSum(n-k+1, n)
    return max - min + 1
}

func main() {
    let nk = readLine()!.split(separator: " ").map{Int($0)!}
    let n = nk[0]
    let k = nk[1]
    var sum = 0
    for i in k...(n+1) {
        sum += combi(n: n, k: i)
        while sum > 1000000007 {
            sum -= 1000000007
        }
    }
    print(sum)
}

main()