#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
ll sum(ll l, ll r)
{
  return (l + r) * (r - l + 1) / 2;
}
int main()
{
  int N, K;
  cin >> N >> K;
  ll sm = 0;
  for (int i = K; i <= N + 1; i++)
  {

    sm += sum(N - i + 1, N) + 1 - sum(0, i - 1);
    sm %= MOD;
  }

  cout << sm << endl;
}