Scanf.scanf "%d %d" (fun n k ->
    let m = 1_000_000_000 + 7 in
    let (+@) a b = (a + b) mod m in
    let rec loop i acc =
        if i > n + 1 then acc else
            let mi = i * (i - 1) / 2 in
            let ma = n * i - mi in
            loop (i + 1) (acc +@ (ma - mi + 1))
    in
    loop k 0 |> Printf.printf "%d\n"
)