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

typedef long long ll;
typedef pair<int, int> pii;

const ll MOD = 1'000'000'007;

ll inv(ll x) {
	ll pow = MOD - 2;
	ll res = 1;

	while (pow > 0) {
		if (pow & 1) {
			res = res * x % MOD;
		}

		pow /= 2;
		x = x * x % MOD;
	}

	return res;
}

ll suff[400'000];
ll pref[400'000];

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

	int n, k;
	cin >> n >> k;

	for (int i = n; i >= 0; i--) {
		suff[i] = i + (i == n ? 0 : suff[i + 1]);
		suff[i] %= MOD;
	}

	pref[0] = 0;

	for (int i = 1; i <= n; i++) {
		pref[i] = pref[i - 1] + i;
		pref[i] %= MOD;
	}

	ll res = 0;

	for (int i = k; i <= n + 1; i++) {
		res = (res + suff[n - i + 1] - pref[i - 1] + 1 + MOD) % MOD;
	}

	cout << res;

	return 0;
}