#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18
const long long MOD = 1000000007;

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    long long ans = 0;
    for (long long i = k; i <= n + 1; i++)
    {
        long long min = (i - 1) * i / 2;
        long long max = (2 * n - i + 1) * i / 2;
        ans += max - min + 1;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}