#include <bits/stdc++.h>
using namespace std;
#define int long long int

int32_t main() 
{
      int p=1000000007;
      int n,k,ans=0;
      cin>>n>>k;
      int i;
      for(i=k;i<=n+1;i++)
      {
            int a,b,c,d;
            a=((i)*(i-1));
            c=(a/2);
            b=((i)*(2*n-i+1));
            d=b/2;
            //cout<<"i "<<i<<" a "<<a<<" b "<<b<<endl;
            ans=(ans+(d-c)+1)%p;
            //cout<<ans<<endl;
      }


      cout<<ans%p<<endl;


	return 0;
}
