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

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

const int MAXN = 2e5;
const ll MOD = 1e9+7;

int N, K;
ll ans;

int main()
{
	int i, j;
	scanf("%d%d", &N, &K);

	ll a=0, b=0;
	for(i=0; i<=N; i++)
	{
		a+=i, b+=N-i;
		if(K-1<=i) ans=((ans+b-a+1)%MOD+MOD)%MOD;
	}
	printf("%lld\n", ans);
}