#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const double PI = acos(-1);
const long long MOD = 1e9 + 7;
int mapa[220000];
long long getsum(long long posi, long long posf) {
  long long res = (posf * (posf + 1) / 2) - ((posi * (posi - 1)) / 2);
  return res;
}
int main() {
  int n, k;
  cin >> n >> k;
  long long tot = 0;
  for (long long i = k; i < n + 2; i++) {
    tot += getsum(n - i + 1, n) - getsum(0, i - 1) + 1;
  }
  cout << tot % MOD << endl;
}
