#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>

// 1 2 3 4
// 3 4 5 6 7 
// 4 - 11
// 

using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

const ll mod = 1000000007;

using namespace std;



int main() {
	int n, k;
	cin >> n >> k;
	ll low = 0;
	ll high = n;
	ll ans = 0;
	
	for (int i = 0; i <= n; i++) {
		//cout << "i:" << i;
		//cout << " low:" << low;
		//cout << " high:" << high;


		 
		if (i >= k - 1) {	
			ans = (ans + (high - low + 1 + mod) % mod) % mod;
			//cout << " ans:" << ans; 
		}
		//cout << endl;

		low = (low + (i + 1)) % mod;
		high = (high + n - i - 1 + mod) % mod;
	} 
	cout << ans << endl;






 	return 0;
}
