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(a: n - i + 1, l: n, n: i)
    let min = sum(a: 0, l: i - 1, n: i)
    return (res + max - min + 1) % mod
})

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

func sum(a: Int, l: Int, n: Int) -> Int {
    return n * (a + l) / 2
}
