#include<stdio.h>
int main(void){
  int nNum;
  int chosenNum;
  int indpNum[20000000];
  int fase;
  int min[20000000];
  int max[20000000];
  int sum = 0;
  
  scanf("%d %d",&nNum,&chosenNum);
  
  for(fase=chosenNum;fase<= nNum+1;fase++){
    min[fase] = ((fase-1)*fase)/2;
   
    max[fase] = (nNum)*(nNum+1)/2 /*キャリーオーバー(計算方法を4+5+...にかえる必要)*/ - (nNum-fase)*(nNum-fase+1)/2;
    //printf("nNum%d \n",nNum);
    //printf("max[%d] = %d \n",fase,max[fase]);
    
    indpNum[fase] = max[fase] - min[fase] + 1 ;
  }
  
  /*
  printf("min%d\n",min[35623]);
  printf("max%d\n",max[35623]);
  printf("%d\n",indpNum[35623]);
  */
  
  for(fase=chosenNum;fase<=nNum+1 ;fase++){
    sum = sum + indpNum[fase];
    //printf("indpNum%d\n",indpNum[fase]);
     
  }
  printf("%d",sum % 1000000007);

}