import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, k) = in.readLine().split("\\s+").map(_.toInt)
    val MOD = 1000000000L + 7

    var sum = 0L

    for(i <- k to (n + 1)) {
      val min = 1L * (i - 1) * i / 2L
      val max = 1L * (n + (n - i + 1)) * i / 2L
      sum = (sum + (max - min + 1)) % MOD
    }

    out.println(sum)

    out.flush()
  }
}
