#include<stdio.h>
typedef long long ll;
const ll mod = 1e9+7;
int main(){
  ll n, k, s, t, len, i, sum;
  scanf("%lld%lld",&n,&k);
  s = 0;
  t = 0;
  sum = 0;
  for(i=0;i<=n;i++){
    s += i;
    t += n - i;
    len = t - s + 1;
    //printf("%lld\n",len);
    if(i+1>=k){
      sum = (sum + len)%mod;
    }
  }
  printf("%lld",sum);
}