#include <bits/stdc++.h>

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

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

  llong ans = 0;
  llong mini = 0, maxi = 0;
  for (int i = 1; i <= N + 1; ++i) {
    mini += i - 1;
    maxi += N - i + 1;

    if (mini <= maxi && i >= K) {
      ans = (ans + (maxi - mini + 1)) % mod;
    }
  }

  cout << ans << endl;

  return 0;
}