#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ld pi = (acos(-1));


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  ll n,k; cin >> n >> k;
  ll ans=0;
  for(ll i=k; i<=n+1;++i){
    ll first = i*(i-1)/2;
    ll last =(n*2-i+1)*i /2;
    ll add = last-first+1;
    ans=(ans+add)%mod;    
  }
  cout << ans << endl; 
}