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

int main(void)
{
  long int i, n, k, min = 0, max = 0, sum = 0, result = 0;
  
  scanf("%ld %ld", &n, &k);
  
  for( i = 0; i <= n; i++ ){
      min += i;
      max += n-i;

      if( i >= k-1 ){
        sum += ( max - min + 1 );
      }
  }

    result = sum % 1000000007;
  printf("%ld\n", result);
  return 0;