#include <stdio.h>
#include <math.h>

int main(void){
  int N,K;
  long int pat=0;
  long int pat2=0;
  long int sum =0;
  scanf("%d",&N);
  scanf("%d",&K);
  for(int k=0;k+K<=N+1;k++){
    sum+=(k+K)*(N-K-k+1)+1;
  }
  printf("%ld",sum%(1000000000+7));
  return 0;
}
