#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long res;
long long n, k;
int main() {
  res = 0;
  cin >> n >> k;
  while (k <= n + 1) {
    long long qian = ((k - 1) * k / 2) % mod,
              hou = ((2 * n % mod - k % mod + 1) * k / 2) % mod;
    res = (res + hou - qian + 1 + mod) % mod;
    k++;
  }
  cout << res;
}
