#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long int
#define MO 1000000007

ll suum(ll a){
  ll ans=a*(a+1)/2;
  return ans;
}

int main(){
  ll n,k;
  scanf("%lld%lld",&n,&k);
  
  ll ans=0;
  for(int i=k;i<=n+1;i++){
    //ll mins = suum(i-1);
    //ll maxs = suum(n)-suum(n-k);
    //ll sa = maxs - mins;
    //sa +=1;
    //ans = (ans+sa)%MO;
    //printf("%lld %lld %lld\n",mins,maxs,sa);
    ans = (ans+(n+1-i)*i+1)%MO;
  }
  
  printf("%lld\n",ans);
  
  return 0;
}
