/*================= *\
|  ID : aman__guta__ |
|      LANG: C++     |
\*==================*/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define ll long long int
#define ld long double 
#define For(i,n) for(int i=0;i<n;i++)
#define Forn(i,n) for(int i=1;i<=n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mk make_pair
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fs first
#define sc second 
#define mod 1000000007
#define sp <<" "<<
#define JOKER ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// typedef tree<lli, null_type, less_equal<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
int spf[10000001];
ll fac[200005];
ll comb[1010][1010];
const ll MAXN=1e6+5;
ll tree[MAXN];
void inc(ll pos);
ll get(ll pos);
ll get_kth(ll k);
void combfun();
void sieve(int n);
int expo(int base,int exponent);
ll power(ll x, ll y, ll p);
ll modInverse(ll n, ll p);
ll nCrModPFormat(ll n, ll r, ll p);
int main()  
{
    JOKER
    int t=1;
    // cin>>t;
    Forn(tc,t)
    {
        ll n,k;
        cin>>n>>k;
        ll sum=0;
        for(ll i=k; i<=n+1; i++)
        {
            ll temp=((i-1)*(i))/2;
            ll temp1=((n+n-i+1)*i)/2;
            // cout<<temp sp temp1<<endl;
            sum+=(temp1-temp+1ll);
            sum%=mod;
        }
        cout<<sum<<endl;
    }
    cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'; 
    return 0;
}

void combfun()
{
    for(int i=1; i<1010; i++)
    {
        for(int j=0; j<=i; j++)
        {
            if(j==0 or i==j)
            {
                comb[i][j]=1;
            }
            else 
            {
                comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
                comb[i][j]%=mod;
            }
        }
    }
}

int expo(int base,int exponent)
{
    ll ans=1;
    while(exponent!=0){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

void sieve(int n)
{
    spf[1]=1;
    for(int i=2;i<=n;i++) spf[i]=i;
    for(int i=4;i<=n;i+=2) spf[i]=2;
    for(int i=3;i*i<=n;i++)
    {
        if(spf[i]==i)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(spf[j]==j) spf[j]=i;
            }
        }
    }
}

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
}

void inc(ll pos) {
    for (; pos < MAXN; pos |= (pos + 1)) {
        tree[pos] += 1;
    }
}
 
ll get(ll pos) {
    ll ans = 0;
    for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
        ans += tree[pos];
    }
    return ans;
}

ll get_kth(ll k) {
    ll l = -1, r = MAXN;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (get(mid) < k) {
            l = mid;
        } else {
            r = mid;
        }
    }
    return r;
}

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 

ll nCrModPFormat(ll n, ll r, ll p) 
{
    if (r==0) 
        return 1; 
    return (fac[n]* modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p; 
}


Measured memory_bytes: 3808