#include <cstdio>
#include <algorithm>
#include <cmath>

using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
template<class T>bool CHMAX(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool CHMIN(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)


int main() {
	ll n,k;
	scanf("%lld", &n);
	scanf("%lld", &k);
	ll sum=0;
	FOR(i, k, n+1) {
		sum += (2 * n - i + 1) * i / 2 - (i - 1) * i / 2 + 1;
	}
	ll res = sum % MOD;
	printf("%lld\n", res);
	return(0);
}