#include<stdio.h>
#define MOD 1000000007
int main(void){
  long long int n,k,ans=0;
  scanf("%lld %lld",&n,&k);
  for(long long int i=k;i<=n+1;i++){
    ans=(ans+(n-i+1)*i+1)%MOD;
  }
  printf("%lld\n",ans);
}