let nk = readLine()!.split(separator: " ").map {
  Int($0)!
}
let n = nk[0]
let k = nk[1]

let mod: Int = 1000000007

func f(_ x: Int) -> Int {
  return x * (n - x + 1) + 1 % mod
}

var c = 0

for i in k...n+1 {
  c += f(i)
  c %= mod
}

print(c)
