#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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 (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    ll left = 0;
    ll right = N;
    REPi(i,1,N+2){
        if(K <= i){
            ll num = right - left + 1;
            //printf("%lld %lld\n", left, right);
            ans += num;
            ans %= MOD;
        }
        left += i;
        right += N-i;
    }

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