import scala.io.StdIn._
import scala.annotation.tailrec

object Main extends App {
  val mod: Long => Long = _ % 1000000007L
  val Array(n, k) = readLine().split(" ").map(_.toInt)

  def sum(l: Long, r: Long): Long = {
    mod(mod(l + r)*mod(r - l + 1))/2
  }

  var ans = 0L
  for {
    i <- k to n + 1
  } yield {
    ans += sum(n - i + 1, n) - sum(0, i - 1) + 1
    ans = mod(ans)
  }
  println(ans)
}
