#include<stdio.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
int main(){
  long long s=0,a=1,n,m,M=1e9+7,i,i2=inv(2,M);;
  scanf("%lld %lld",&n,&m);
  for(i=m;i<n+2;i++){
    s=(s+(i*(n-i+n+1)%M*i2)%M)%M;//printf("%lld\n",(i*(n-i+n+1)%M*i2)%M);
    s=(s+1+M-((i-1)*(i)%M*i2)%M)%M;
    //printf("!%lld\n",((i-1)*(i)%M*i2)%M);
  }
  printf("%lld\n",s);
  return 0;
}
