#include<bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  ll N,K; cin>>N>>K;
  ll res = 0;
  for(ll i = K; i <= N+1; i++){
    ll s = i*(i-1)/2;
    ll e = i*N - s;
    s%=MOD;
    //e%=MOD;
    //cout<<s<<" "<<e<<endl;
    res += (e-s+1)%MOD;
  }
  cout<<res%MOD<<endl;
}