#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


//abc163D
int main(void) {
  //int n, k, i, a, cou=0, tmp;
  long long n, k, i, a, cou=0, tmp;
  long long mod=1000000007,sum=0;
  scanf(" %lld %lld", &n,&k);


  for(i=k; i <=n+1; i++){
    sum=(sum+(n+1-i)*i+1)%mod;
  }

  printf("%lld",sum);
  return 0;
}