#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, k;
  cin >> n >> k;
  int64_t count = 0;
  for (int i = k; i <= n + 1; i++) {
    count += (n - i + 1) * i + 1;
    count %= 1000000007;
  }
  cout << count << endl;
  return 0;
}
