#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll cnt = 0;
    vector<ll> vc(n+1);
    vc[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        vc[i] = (vc[i - 1] + i);
    }

    for (int i = k-1; i <= n; i++)
    {
        ll max = vc[vc.size()-1]-vc[n-i-1];
        ll min = vc[i];
        cnt += (max - min + 1)%MOD;
        cnt %=MOD;
    }
    cout << cnt << endl;
}