#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (ll i = K; i < N + 2; i++)
    {
        ll sum1 = i * (i - 1) / 2;
        ll sum2 = i * ((N - i + 1) + N) / 2;
        ll sum = (sum2 % MOD - sum1 % MOD) % MOD;
        if (sum < 0)
        {
            sum += MOD;
        }
        ans += (sum + 1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}