#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
int a[200005];
int main() {
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= 200001; i++) a[i] = (a[i - 1] + i) % mod;
  long long sum = 0;
  for (long long i = k - 1; i <= n; i++)
    sum = (sum + a[n] - a[i] - (i == n ? 0 : a[n - i - 1]) + 1) % mod;
  while (sum < 0) sum += mod;
  cout << sum << endl;
}
