











import Foundation
let main: () = {
    let (N, M) = *listOfInt()
    var s = Array(N + 1) { $0 }
    s.insert(0, at: 0)
    for n in 1 ... N + 1 { s[n] += s[n - 1] }
    var ans = 0
    for n in M ... N + 1 {
        let min = s[n] - s.first!
        let max = s.last! - s[N - n + 1]
        ans += max - min + 1
        ans %= 1000000007
    }
    print(ans)
}()

@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func listOfString() -> [String] { next().split(separator: " ").map(String.init) }
@inlinable func listOfInt() -> [Int] { listOfString().map { Int($0)! } }
extension Array {
    init(_ size: Int, _ initValue: ((Int) -> Element)) {
        self = [Element]()
        for index in 0 ..< size {
            let value = initValue(index)
            self.append(value)
        }
    }
}

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) { (a[0], a[1]) }
