#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans,cnt;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n,k;
	cin >> n >> k;
	
	for (ll i = k; i <= n + 1; i++) {
		ll l = (i * (i - 1)) / 2;
		ll r = (2 * n - i + 1) * i / 2;
		ans += r - l + 1;
	}
	
	cout << ans % MOD << endl;

	return 0;
}