#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
const double pi = acos(-1.0);
const int maxn = (long long int)1e9 + 7;
long long int arr[200005];
int main() {
  int n, k;
  long long int sum = 0;
  cin >> n >> k;
  for (int i = 1; i <= 200001; i++) arr[i] = arr[i - 1] + i;
  for (int i = k; i <= (n + 1); i++) {
    long long int mn = arr[i - 1];
    long long int mx = arr[n] - arr[n - i];
    sum += (mx - mn + 1);
    sum %= maxn;
  }
  cout << sum;
  return 0;
}
