#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


//mod計算用のクラス
class ModInt{
public:
    long long int x;
    long long int mod;
	ModInt(){}
    ModInt(long long int _x, long long int _mod = 1000000007){
        this->x = _x % _mod;
        this->mod = _mod;
    }
	ModInt operator+(ModInt other){
		return ModInt(this->x + (other.x % this->mod),this->mod);
	}
	ModInt operator-(ModInt other){
		long long int res = this->x - (other.x % this->mod);
		if (res < 0) return ModInt(res + this->mod, this->mod);
		return ModInt(res);
	}
	ModInt operator*(ModInt other){
		return ModInt(this->x * (other.x % this->mod),this->mod);
	}
	ModInt operator/(ModInt other){
		return ModInt(*this * other.inv());
	}
	ModInt pow(long long int n){
		ModInt res(1, this->mod), a(this->x, this->mod);
		while (n){
			if (n & 1){
				res = res * a;
			}
			n >>= 1;
			a = a * a;
		}
		return res;
	}
	ModInt inv(){
		return ModInt(this->pow(this->mod - 2));
	}
	void disp(){
		cout << this->x << endl;
	}
};
ostream& operator<<(ostream& stream, const ModInt m){
	stream << to_string(m.x);
	return stream;
}

//mod nCrを返す関数.何回も計算するときはこっち.ModIntが必要.
class modcomb{
	public:
		vector<ModInt> fact;
		vector<ModInt> ifact;
		modcomb(){}
		modcomb(int n){
			this->fact.resize(n + 1, ModInt(1));
			this->ifact.resize(n + 1, ModInt(1));
			for (int i = 1; i <= n;i++)
				this->fact[i] = this->fact[i - 1] * i;
			this->ifact[n] = fact[n].inv();
			for (int i = n; i >= 1; --i)
				this->ifact[i - 1] = ifact[i] * i;
		}
		ModInt operator()(int n, int k){
			if (k < 0 || k > n)
				return 0;
			return this->fact[n] * this->ifact[k] * this->ifact[n - k];
		}
};

int main()
{
	ll mod = 1e9 + 7;
	int n, k;
	cin >> n >> k;
	vector<ll> r(n + 1, 0);
	rep(i,n){
		r[i + 1] = r[i] + i+1;
	}
	ll ans = 0;
	rep2(i, k, n + 1)
	{
		
		ans += (r[n] - r[n - i]) - (r[i - 1] - r[0]) + 1;
		ans %= mod;
		// cout << ans << endl;
	}
	// cout << r[n] << " " << r[n - 2] << " " << r[1] << " " << r[0] << endl;
	cout << ans + 1 << endl;

	return 0;
}

Measured memory_bytes: 4776