#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 10;
const long long inf = 1e18 + 100;
const long long mod = 1e9 + 7;
void solve() {
  long long n, k;
  cin >> n >> k;
  long long sum = 0;
  for (int i = k; i <= n + 1; i++) {
    long long k = i * (n - i + 1) + 1;
    sum = sum % mod + k % mod;
    sum %= mod;
  }
  cout << sum << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
