#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)


int main(){
	long int n, k;
	scanf("%ld%ld", &n, &k);
	
	long int ans=0;
	for(; k<=n+1; k++){
		ans += (n-k+1)*k+1;
		ans = ans%MOD;
	}

	printf("%d\n", ans);
	
	return 0;
}