#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
using ll=long long;
using namespace std;
const ll mod=1e9+7;
int main(){
    ll n,k,ans=0;
    cin>>n>>k;
    rep(i,k,n+2)ans=(ans+i*(n-i+1)+1)%mod;
    cout<<ans;
}