import scala.annotation.tailrec
object Main extends App {

  import scala.io.StdIn._
  val mod = 1000000007L
  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  var result = 0L
  for (i <- k to n + 1) {
    result += 1 + sum(n, i) % mod
    result += mod - sum(i - 1) % mod
    result %= mod
  }
  println(result)

  def sum(n: Long): Long = {
    n * (n + 1) / 2
  }
  def sum(upper: Long, count: Long): Long = {
    sum(upper) - sum(upper - count)
  }
}