#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    const ll MOD = 1e9+7;
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for(ll i=K; i<=N+1; i++){
        ans += i * (N-i+1) + 1;
        ans %= MOD;
    }

    cout << ans << endl;
}