#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  ll ret = 0;
  vector<ll> sum(n+1);
  sum[1] = 1;
  for (ll i = 2 ; i <= n ; i++ ) { // range [0,n-1]
    sum[i] = sum[i-1] + i;
    //sum[i] %= MOD;
  }
  for (int l = k ; l <= n+1 ; l++ ) {
    ll mins = 0;
    ll maxs = 0;
    mins = sum[l-1];
    if( l >= n ) maxs = sum[n];
    else {
      maxs = sum[n] - sum[n-l];
    }
    //cout << "max" << maxs << endl;
    //cout << "min" << mins << endl;

    ret += (maxs - mins + 1 );
    ret %= MOD;
  }
  cout << ret << endl;

  return 0;

}

