#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, k, sum = 1, mod = 1000000007;

ll gauss(ll n)
{
    return (n * (n + 1) / 2) % mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    while (k <= n)
    {
        ll min = gauss(k - 1);
        ll max = (gauss(n) - gauss(n - k) + mod) % mod;
        sum += (max - min + 1 + mod) % mod;
        k++;
    }

    cout << sum % mod;
    cin >> n;
}