#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
 
int main()
{

    ll ans=0,n,k,temp=0,i;
    cin >> n >> k ;
    if(n==1)
    {
        if(k==1) 
            cout << 2 ;
        else 
            cout << 1 ;
    }
    for(i=k;i<=n+1;++i)
    {
        temp = (i*(n+1-i)+1)%mod ;
        ans=(ans+temp)%mod;
    }
    cout << ans%mod ;
}
 