#include <bits/stdc++.h>
using LL = long long;
using namespace std;
const LL mod = 1e9 + 7;
int main() {
	LL n, k; cin >> n >> k;
	LL pre_sum[n + 1] = {};
	for (LL i = 1; i <= n; i++) {
		pre_sum[i] = pre_sum[i - 1] + i;
	}
	LL ans = 1;
	for (LL i = k; i <= n; i++) {
		// if (i <= 5)
		// 	cout << ans << "\n";
		ans = (ans + pre_sum[n] - pre_sum[n - i] - pre_sum[i - 1] + 1) % mod;
		// if (i <= 5)
		// cout << pre_sum[n] << ' ' << pre_sum[n - i]
		// 	 << ' ' << pre_sum[i - 1] << "\n";
		// if (i <= 5)
		// 	cout << ans << "\n";
	}
	cout << ans;
}