#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define mod (1000000007)
void solve() 
{
    ll n,k;cin>>n>>k;
    ll mn[n+1],mx[n+1];mn[0]=0;mx[0]=n;
    rep(i,1,n+1){
        mn[i]=mn[i-1]+i;
        mx[i]=mx[i-1]+(n-i);
    }
    ll ans=0;
    for(int i=k-1;i<=n;i++){
        // cout<<mx[i]-mn[i]+1<<endl;
        ans+=mx[i]-mn[i]+1;
        ans%=mod;
    }
    cout<<ans<<endl;
    
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}