#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

ll MOD = 1e+9 + 7;

ll sum(ll a, ll b) {
    return (a + b) * (b - a + 1) / 2;
}

int main() {
    ll n, k, l, r, ans = 0;
    cin >> n >> k;

    for (ll i = k; i <= n + 1; i++) {
        l = sum(0, i - 1);
        r = sum(n - i + 1, n);
        ans += (r - l + 1) % MOD;
    }
    cout << ans % MOD << endl;

    return 0;
}