#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

#define rep(i,n) for(int i = 0; i < n; ++i)

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, T& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

class modint_t {
public:
    modint_t() = default;
    modint_t(int64_t value):value(value % MOD){}

    bool operator<(const modint_t rhs) const { return value < rhs.value; }
    bool operator<=(const modint_t rhs) const { return value <= rhs.value; }
    bool operator>(const modint_t rhs) const { return value > rhs.value; }
    bool operator>=(const modint_t rhs) const { return value >= rhs.value; }

    modint_t operator+(const modint_t rhs) const { return modint_t(value + rhs.value); }
    modint_t operator+=(const modint_t rhs) { return value = (value + rhs.value) % MOD; }
    modint_t operator-(const modint_t rhs) const { return modint_t(MOD + value - rhs.value); }
    modint_t operator-=(const modint_t rhs) { return value = (MOD + value - rhs.value) % MOD; }

    modint_t operator*(const modint_t rhs) const { return modint_t(value * rhs.value); }
    modint_t operator*=(const modint_t rhs) { return value = value * rhs.value % MOD; }
    modint_t operator/(const modint_t rhs) const { return *this * rhs.invert(); }
    modint_t operator/=(const modint_t rhs) { return *this *= rhs.invert(); }

    modint_t square() const { return *this * *this; }
    modint_t power(int64_t y) const
    {
        if(y == 0) return 1;
        else if(y == 1) return *this;
        else if(y % 2 == 0) return this->power(y/2).square();
        else return *this * this->power(y-1);
    }

    modint_t invert() const
    {
        return power(MOD-2);
    }

    operator int64_t() const
    {
        return value;
    }
private:
    static const int MOD = 1000000007;
    int64_t value = 0;
};

modint_t factorial(int64_t n)
{
    if(n <= 1) return 1;
    modint_t f = 1;
    for(int64_t i = 1; i <= n; ++i)
    {
        f *= i;
    }
    return f;
}

modint_t permutation(int64_t n, int64_t r)
{
    modint_t p = 1;
    for(int64_t i = n; i > n-r; --i)
    {
        p *= i;
    }
    return p;
}

modint_t combination(int64_t n, int64_t r)
{
    if(r * 2 > n) r = n - r;
    modint_t x = 1;
    modint_t y = 1;
    for(int64_t i = 1; i <= r; ++i)
    {
        x *= n - i + 1;
        y *= i;
    }
    return x / y;
}

void solution()
{
    int n, k;
    cin >> n >> k;
    modint_t min_sum;
    modint_t max_sum;
    for(int i = 0; i < k; ++i){
        min_sum += i;
        max_sum += n - i;
    }
    modint_t count;
    for(int i = k; i <= n + 1; ++i){
        count += (modint_t(1) + max_sum - min_sum);
        //cout << "use " << i << " numbers: max=" << max_sum << ", min=" << min_sum << '\n';
        min_sum += i;
        max_sum += n - i;
    }
    cout << count << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}


Measured memory_bytes: 3584