#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	ll n, k;
	cin >> n >> k;
	ll ans = 0;

	for (ll i = k; i <= n; i++){
		ans += (n*(n+1)/2)%MOD - ((n-i)*(n-i+1)/2)%MOD - ((i-1)*i/2)%MOD + 1;
		ans %= MOD;
	}

	if((ans+1)%MOD < 0) cout << (ans+1)%MOD+MOD << endl;
	else cout << (ans+1)%MOD  << endl;
	return 0;
}
