#include<stdio.h>
#include<limits.h>
#define MM 1000000007
#define ll unsigned long long
int main(){
	ll all=0,i,n,k;
	scanf("%llu%llu",&n,&k);
	for(i=k;i<=n+1;++i){
		unsigned int temp=i*(n-i+1)%MM;
		all%=MM;
		all=all+temp+1;
	}
	printf("%llu",all%MM);
	return 0;
}