#include <stdio.h>
#define MOD 1000000007
typedef long long ll;
ll min[200000], max[200000];
int main() {
	int n, k;
	ll sum = 0;
	scanf("%d%d", &n, &k);
	min[0] = 0;
	max[0] = n;
	for (int i = 1; i <= n; i++) {
		min[i] = min[i - 1] + i;
	}
	for (int i = 1; i <= n; i++) {
		max[i] = max[i - 1] + n - i;
	}
	for (int i = k; i <= n + 1; i++) {
		// i個選んだ時の個数+
		sum += max[i-1] - min[i-1] + 1;
		sum %= MOD;
	}
	printf("%lld\n", sum);
	return 0;
}