#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i <= n + 1; ++i) {
		ll mx = (n - i + n + 1) * i / 2;
		ll mn = i * (i - 1) / 2;
		(ans += mx - mn + 1) %= mod;
	}
	cout << ans << endl;
	return 0;
}
