#include<stdio.h>
int main()
{
    int N,K;
    unsigned long long sum1=0,sum2=0,i,m=1000000007,a;
    scanf("%d%d",&N,&K);
    for(i=K;i<=(N+1);i++){
        sum1=(sum1+i)%m;
    }
    for(i=K;i<=(N+1);i++){
        sum2=(sum2+i*(i-1))%m;
    }
    a=(N*sum1)%m;
    a=(a+N-K+2)%m;
    a=(a-sum2)%m;
    printf("%llu\n",a);
    return 0;
}
