#include<stdio.h>
int main(){
  int n,k;
  long long int max=0,min=0,i;
  long long int count=0;
  scanf("%d%d",&n,&k);
  for(i=0;i<k;i++){
    max+=n-i;
    min+=i;
  }
  count+=max-min+1;
  for(i=k;i<=n;i++){
    max+=n-i;
    min+=i;
    count+=max-min+1;
    count%=1000000007;
  }
  printf("%d\n",count);
  return 0;
}
