#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

const ll MOD = 1'000'000'007;

ll mod(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}

ll f(ll l, ll r) {
  ll res = (r * (r + 1)) / 2 - ((l - 1) * l) / 2;
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;

  ll res = 0;
  for (ll i = k; i <= n + 1; ++i) {
    ll maxV = f(n - i + 1, n);
    ll minV = f(0, i - 1);
    res = (res + ((maxV - minV + 1) % MOD)) % MOD;
  }
  cout << res << endl;

  return 0;
}
