#include <stdio.h>
int main(){
  long int N,K,count,i,j,con,max,min;
  scanf("%ld %ld",&N,&K);
  count=0;
  min=0;
  max=0;
  for(i=0;i<N+1;i++){
    min=min+i;
    max=max+(N-i);
    if(i>=K-1){
      con=max-min+1;
      count=count+con;
    }
  }
  count=count%1000000007;
  printf("%ld",count);
  return 0;
}