#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (ll i = 0;i < (a);++i)
#define FOR(i,a,b) for (ll i = (a);i < (b); ++i)
#define FORR(i,a,b) for (ll i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,k;
    cin >> n >> k;
    ll answer = 0;

    ll min_sum = 0,max_sum = 0;
    REP(j,k-1){
        min_sum=(min_sum+j)%MOD;
    }
    FORR(j,n,n-k+2){
        max_sum=(max_sum+j)%MOD;
    }
    FOR(i,k,n+2){
        min_sum=(min_sum+(i-1))%MOD;
        max_sum=(max_sum+(n-i+1))%MOD;
        answer = (answer+(max_sum-min_sum)+1)%MOD;
    }
    while(answer < 0){
        answer += MOD;
    }
    cout << answer << endl;
    return 0;
}