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

long long int n, k;
long long int M = 1e+9 + 7;
int main()
{
    cin >> n >> k;
    long long int ans = 1, s1 = 0, s2 = 0;
    for (long long int i = n; i > n - k; i--)
        s2 += i;
    for (long long int i = 0; i < k; i++)
        s1 += i;
    for (long long int i = k; i <= n; i++)
    {
        // cout<<s1<<" "<<s2;
        ans = ((ans + (s2 - s1+1) % M) % M + M) % M;
        s2 += n - i;
        s1 += i;
    }
    cout<<ans;
}