#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

const ll MOD = 1000000007;

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

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

	cout << ans << endl;
	return 0;
}