#include <bits/stdc++.h>
using namespace std;

int main() {
  long long int n, k, ans = 0, mod = 1000000007;
  cin >> n >> k;

  for (long long int i = k; i <= n + 1; i++) {
    ans += (n * i - i * (i - 1) + 1) % mod;
  }
  cout << ans % mod << endl;
}