#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ll N, K;
	cin >> N >> K;
	ll ans = 0;
	const ll mod = 1000000007;
	for (ll k = K; k <= N + 1; ++k) {
		(ans += k * (N - k + 1) + 1) %= mod;
	}
	cout << ans << endl;
}