#include <iostream>
#include <algorithm> 
#include<vector>
using namespace std;

const int mod = 1e9 + 7;
int main()
{
	long long n, k;
	scanf_s("%lld%lld", &n, &k);
	long long  cnt = 0;
	for (int i = k; i <= n; i++)
	{
		cnt += (n - i + 1 + n)*i / 2 - (i - 1)*i / 2 + 1;
		cnt %= mod;
	}
	cnt++;
	cnt %= mod;
	printf("%lld\n", cnt);
}