#include <bits/stdc++.h>
using namespace std;
const long long MOD = pow(10, 9) + 7;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> sum_f(n + 3);
  sum_f[3] = 2;
  for (int i = 4; i <= n + 2; i++) {
    sum_f[i] = sum_f[i - 1] + (i - 1);
  }
  vector<long long> sum_b(n + 3);
  sum_b[1] = n;
  for (int i = 2; i <= n + 2; i++) {
    sum_b[i] = sum_b[i - 1] + (sum_b[1] - (i - 1));
  }
  long long ans = 0;
  for (int i = k; i <= n + 1; i++) {
    ans += sum_b[i] - sum_f[i];
    ans %= MOD;
  }
  cout << ans << endl;
}
