function main(input) {
  let n,k = 0;
  [n, k] = input[0].trim().split(" ").map(i => parseInt(i));

  let sum = 0;

  function　sum1toN(n) {
    return n*(n+1)/2;
  }

  for(let i=k;i<=n+1;i++){
    const min = sum1toN(i-1);
    const max = sum1toN(n) - sum1toN(n-i);
    sum = (sum+(max-min+1))%(10**9+7);
  }
  console.log(sum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));