#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll MOD = (ll)pow(10, 9) + 7;

int main(){
  ll N, K;
  cin >> N >> K;

  ll ans = 0;

  rep2(k, K, N + 2){
    ans += (ll)k * (ll)(2*N - k + 1) / 2 - (ll)k * (ll)(k - 1) / 2 + 1;
    ans %= MOD;
  }

  cout << ans << endl;
  
  return 0;
}
