#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n, k;
cin >> n >> k;
vector<ll> cum(int(2*1e5)+1,0);
reps(i,2*1e5+1,1){
    cum[i] =cum[i-1]+ i-1;
}

//選ぶ数字の数毎に組合せは重複しない
ll ans = 0;
reps(i,n+2,k){
    ll _min = cum[i];
    ll _max = cum[n+1]-cum[n+1-i];
    ans = (ans + _max - _min + 1)%MOD;
}

cout << ans << endl;

//system("pause");
return 0;
}