#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define MOD 1000000007

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

    vector<ll> a(n + 2);

    for (int i = 1; i <= n; i++) {
        a[i + 1] = a[i] + i;
    }

    int ans = 0;
    for (int i = k; i <= n; i++) {
        ans = (ans + a[n + 1] - a[n + 1 - i] - a[i] + 1) % MOD;
    }

    cout << ans + 1 % MOD << endl;

    return 0;
}