#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<ll,ll>;
//const int 1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;

int main(){
	int n,k;
	cin>>n>>k;
	vector<int> l(n+1);
	vector<int> r(n+1);
	int cnt=0;
	for(int i=0;i<=n;i++){
		cnt+=i;
		cnt%=MOD;
		l[i]=cnt;
	}
	cnt=0;
	for(int i=n;i>=0;i--){
		cnt+=i;
		cnt%=MOD;
		r[i]=cnt;
	}
  int ans=0;
  for(int i=k;i<=n+1;i++){
		ans+=r[n-i+1]-l[i-1]+1;
	//	cout<<ans<<endl;
		ans%=MOD;
	}
	cout<<ans;







}
