#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i)++)
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)
#define abs(a) (a)>0?(a):-(a)
#define llong long long
#define P (1000000007)

llong mpow(llong a,llong b){
	llong ans = 1;
	while(b){
		if(b&1) ans = ans*a%P;
		b = b>>1; a = a*a%P;
	}
	return ans;
}

int main(){
	llong N,K; scanf("%lld %lld",&N,&K);
	llong a = K-N-2;
	llong b = ((2*K*K%P)-(K*(N+2))%P-(N*N+N+6)%P)%P;
	if( a<0 ) a+=P;
	if( b<0 ) b+=P;
	llong ans = ((a*b)%P*mpow(6,1000000005))%P;
	printf("%lld",ans);
}
