#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> a(n + 1);
    rep(i, n + 1)a[i] = i;
    vector<ll> a_sum(n + 2);
    a_sum[0] = 0;
    _rep(i, 1, n + 2){
        a_sum[i] = a_sum[i - 1] + a[i - 1];
        //cout << a_sum[i] << endl;
    }

    ll ans = 0;
    rep(i, n - k + 2){
        ans += (a_sum[n + 1] - a_sum[(n + 1 - k) - i]) - a_sum[k + i] + 1;    
        ans %= mod;
        //cout << ans << endl;
    }
    cout << ans << endl;
}