protocol InitFromString {
    init?(_ str: String)
}

extension Int: InitFromString {}
extension Int8: InitFromString {}
extension Int16: InitFromString {}
extension Int32: InitFromString {}
extension Int64: InitFromString {}
extension String: InitFromString {}

func input<T: InitFromString>() -> [T] {
    readLine()!.split(separator: " ").map(String.init).compactMap(T.init)
}

let nk: [Int] = input()
let n = nk[0]
let k = nk[1]

let mod = 1000_000_000 + 7

let result = (k...(n+1)).reduce(0, { res, i in
    let max = sum([Int]((n-i)...n))
    let min = sum([Int](0..<i))
    return (res + max - min + 1) % mod
})

print(result == 0 ? 1 : result % mod)

func sum(_ arr: [Int]) -> Int {
    return (arr.first! + arr.last!) * arr.count / 2
}
