#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	ll n, k; cin >> n >> k;
	ll ans = 0;
	// 4
	//01 ~ 23 : 1 ~ 5 : 5
	//012 ~ 123 : 3 ~ 6 : 4
	//0123 : 1
	//n - k
	for (ll i = k; i <= n; i++) {
		ll t = n - i;
		ll Left = (i - 1) * i / (ll)2;
		ll Right = n * (n + 1) / (ll)2 - t * (t + 1) / (ll)2;
		ans += (Right - Left + (ll)1);
		ans %= mod;
	}

	cout << (ans + 1) % mod << '\n';

}