#include <bits/stdc++.h>
using namespace std;
int main() {
  long long ans = 0, n, k, temp = 0, i;
  cin >> n >> k;
  if (n == 1) {
    if (k == 1)
      cout << 2;
    else
      cout << 1;
  }
  for (i = k; i <= n + 1; ++i) {
    temp = (i * (n + 1 - i) + 1) % 1000000007;
    ans = (ans + temp) % 1000000007;
  }
  cout << ans % 1000000007;
}
