#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 1000000007
typedef long long ll;
int N,K;

ll rem=0;
ll Sum(ll num){
	ll sum=0;
	ll sum2=0;
	if(num == N+2){
		return 0;
	}

	sum=((num-1)%BUFSIZE)*(num%BUFSIZE)/2;

	sum2=(N*2+1-num)*num/2;
	rem=rem + sum2 - sum + 1;
	rem=rem%BUFSIZE;
	Sum(num+1);
	return 0;
}

int main(void){
	scanf("%d",&N);
	scanf("%d",&K);
	if(N < K){
		printf("1");
		exit(0);
	}
	
	Sum(K);
	
		printf("%lld",rem%BUFSIZE);
	
}