#include<stdio.h>
int main(void){
	#define N 1000000007
	long n, k;
	long x = 0;
	scanf("%ld", &n);
	scanf("%ld", &k);
	for(long i=k; i<=n+1; i++){
		long current_diff = (i*(n-i+1) + 1);
		x = (x+current_diff)%N;
	}
	printf("%ld\n", x);
	return 0;
}