#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  for (; k <= n + 1; ++k) {
    ll max = ((n + 1) + (n + 1 - k + 1)) * k / 2;
    ll min = k * (k + 1) / 2 - 1;
    ans += max - min;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
