#include <stdio.h>
long long p = 1000000007;
long long n, k, x, ans;
int main() {
	scanf("%lld%lld", &n, &k);
	for (long long i = k; i <= n + 1; i++) {
		x = (2 * n - i + 1) * i - (i - 1) * i;
		x /= 2;
		ans += x + 1;
		ans %= p;
	}
	printf("%lld\n", ans);
}