#include<stdio.h>
#include<math.h>
int m=1e9+7;
int main()
{
    long long int n,k,a[200005],c,i,b[200005],j;long long s=0;
    scanf("%lld %lld",&n,&k);
    a[0]=0;b[n]=n;
    for(i=1;i<=200004;i++)
    {
        a[i]=(a[i-1]+i);
    }
    for(i=n;i>=0;i--)
    {
        b[i]=(b[i+1]+i);
    }
        //for(i=k-1,j=n-k+1;i<=n;i++,j--)
    //{
        //printf("%d\n",b[j]-a[i]);
   // }

    for(i=k-1,j=n-k+1;i<=n;i++,j--)
    {
        s=s+(b[j]-a[i]+1);
        s%=m;
    }

        printf("%lld",s%m);

}
