#include<cstdio>

typedef long long ll;
const ll mod = 1E+9 + 7;

ll n, k, ans;

int main() {
	scanf("%lld%lld", &n, &k);
	while(k <= n + 1) {
		ans = (ans + (2 * n - k + 1) * k / 2 - (k - 1) * k / 2 + 1) % mod;
		++k;
	}
	printf("%lld", ans);
}