/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;

#define io(F) string t_="";ifstream fin(t_+F+".in");ofstreamfout(t_+F+".out")
#define qio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define graph unordered_map<int, unordered_set<int>>
typedef long long ll;

ll ps[300000];

int main() {
	qio; ll n, k; cin >> n >> k;
	forl(i, 0, 299999) { ps[i] += i; ps[i+1] += ps[i]; }
	ll tot = 0;
	forl(i, k-1, n+1) {
		if(i == n) tot += 1;
		else tot += ps[n]-ps[n-i-1]-ps[i]+1;
		tot %= 1000000007;
	}
	println(tot);
}
