#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll mod = 1000000007;
    ll N,K;
    cin >> N >> K;
    ll out = 0;
    for(ll i=K;i<=N+1;i++){
        ll min = (i*(i-1)/2)%mod;
        ll max = ((N+N-i+1)*i/2)%mod;
        out += (max-min+1)%mod;
    }
    cout << out%mod << endl;
    return 0;
}
