#include<stdio.h>
#define P 1000000007
int main(){
    int n,k;
    long long b;
    int c;
    long long  sum=0;
    int s;
    scanf("%d %d",&n,&k);
    for(int i=k;i<=n+1;i++){
        b=i*(n+1-i)+1;
        c=b%P;
    	sum=sum%P;
    	sum=sum+c;
    	sum=sum%P;
    	//printf("%d\n",i*(n+1-i)+1);
    }
    s=sum;
    printf("%d\n",s);
	return 0;
}