#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  long long max = 0, min = 0, ans = 0;
  for (long long i = k; i <= n + 1; i++) {
    min = (i * (i - 1)) / 2;
    max = ((n + 1) * n) / 2;
    max -= ((n - i + 1) * (n - i)) / 2;
    ans += (max - min + 1);
  }
  ans %= 1000000007;
  cout << ans << endl;
  return 0;
}
