#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,k;
    cin>>n>>k;
    ll ans = 0;
    ll mod = 1e9+7;
    for(ll i=k;i<=n+1;i++){
        ll ma = n*(n+1)/2LL - (n-i)*(n-i+1)/2LL;
        ma %= mod;
        ll mi = (i-1)*i/2LL;
        mi %= mod;
        ans += mod + ma - mi+1;
        ans %= mod;
       // cerr << i << " " << ma << " " << mi << endl;
    }
    cout << ans << endl;
    
}