#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

ll nCr(ll n, ll k){
    ll res = 1;
    ll resd = 1;
    if ( k > n - k )
        k = n - k;
    for (ll i = 0; i < k; ++i){
        res *= (n - i);
        resd *= (i + 1);
    }
    return divi(res, resd);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	ll n, k;
	cin>>n>>k;
	ll ans = 0;
	ll x =0;
	ll maxs=0;
	for(int i=0;i<k;i++){
		x+=i;
		maxs+=(n-i);
	}
	for(int i=k; i<=n+1;i++){

		ans = add(ans,(maxs + 1 - x+mod)%mod);
		x+=i;
		maxs+=(n-i);
	}
	cout<<ans%mod;
	
	return 0;
}
