#include <stdio.h>
#include <string.h>
#define MM 1000000007
long A[1000100];
int main(){

	long int i,j;
	long int x,y,a,b,c;
	long N,M,K,tmp;
	long long sum=0;
	scanf("%ld%ld",&N,&K);
	long low=0,high=0,Num=0;
	for(i=0;i<K;i++){
		low+=i;
		high+=N-i;
	}
	//printf("%ld %ld\n",low,high);
	for(i=K;i<=N;i++){
		//min
		Num+=high-low+1;
		if(Num>=MM) Num%=MM;
		low+=i;
		high+=N-i;
		//printf("%ld %ld\n",low,high);
	}
		Num+=high-low+1;
		if(Num>=MM) Num%=MM;	
	printf("%ld\n",Num);

	return 0;
}
