//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
	



int main(){
   IOS

	int n, k; cin>>n>>k;

	vector<ll> v;
	v.pb(0); v.pb(0);
	for(int i = 1; i <= n; i++){
		v.pb(v.back() + i);
	}

	ll ans = 0;
	for(int r = k; r <= n+1; r++){
		ll lo = v[r] - v[0];
		ll hi = v[n + 1] - v[n + 1 - r];
		//cout<<lo<<" "<<hi<<"\n";
		ans += (hi - lo + 1 + mod)%mod;
		if(ans >= mod)ans -= mod;
	}

	cout<<ans<<"\n";







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
	if(b&1)
		res = res * a % mod;
		a = a * a % mod;
	b >>= 1;
	}

	return res;
}

