#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[2] = {0, 1};
ll dy[2] = {1, 0};

int main(void){
    ll n, k;
    cin >> n >> k;
    ll INF = 1e+9+7;
    vector<ll> sa(n+1, 0);
    vector<ll> sb(n+1, 0);
    sb[0] = n;
    for(ll i = 1; i <= n; i++){
        sa[i] = sa[i-1]+i;
        sb[i] = sb[i-1]+(n-i);
    }
    ll ans = 0;
    for(ll i = 0; i <= n; i++){
        if(i>=k-1){
            ans+=(sb[i]-sa[i]+1);
            ans%=INF;
        }
    }
    cout << ans << endl;
    return 0;
}
