let input f = stdin.ReadLine() |> f
let inputs f = stdin.ReadLine().Split() |> Array.map f

let md = 1000000007L

let [|N; K|] = inputs int

let S l r = r * (r + 1L) / 2L - l * (l - 1L) / 2L


[for i in K..N+1 ->
    let l = S 0L (int64 (i - 1)) in
    let r = S (int64 (N-i+1)) (int64 N) in
    r - l + 1L]
|> List.sum
|> (fun x -> x % md)
|> printfn "%d"
