#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

template <int Modulus>
struct ModInt {
    long long val;
    constexpr ModInt(const long long v = 0) noexcept : val(v % Modulus) {
        if (val < 0) val += Modulus;
    }

    constexpr ModInt operator + (const ModInt& r) const noexcept { return ModInt(*this) += r; }
    constexpr ModInt operator - (const ModInt& r) const noexcept { return ModInt(*this) -= r; }
    constexpr ModInt operator * (const ModInt& r) const noexcept { return ModInt(*this) *= r; }
    constexpr ModInt operator / (const ModInt& r) const noexcept { return ModInt(*this) /= r; }
    
    constexpr ModInt& operator += (const ModInt& r) noexcept {
        val += r.val;
        if (val >= Modulus) val -= Modulus;
        return *this;
    }
    constexpr ModInt& operator -= (const ModInt& r) noexcept {
        val -= r.val;
        if (val < 0) val += Modulus;
        return *this;
    }
    constexpr ModInt& operator *= (const ModInt& r) noexcept {
        val = val * r.val % Modulus;
        return *this;
    }
    constexpr ModInt& operator /= (const ModInt& r) noexcept {
        long long a = r.val, b = Modulus, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % Modulus;
        if (val < 0) val += Modulus;
        return *this;
    }

    constexpr bool operator == (const ModInt& r) const noexcept { return val == r.val; }
    constexpr bool operator != (const ModInt& r) const noexcept { return val != r.val; }
    constexpr bool operator < (const ModInt& r) const noexcept { return val < r.val; }
    constexpr bool operator <= (const ModInt& r) const noexcept { return val <= r.val; }
    constexpr bool operator > (const ModInt& r) const noexcept { return val > r.val; }
    constexpr bool operator >= (const ModInt& r) const noexcept { return val >= r.val; }

    constexpr ModInt operator - () const noexcept {
        return val ? Modulus - val : 0;
    }

    ModInt pow(long long n) {
        ModInt res(1), tmp(val);
        while (n > 0) {
            if (n & 1) res *= tmp;
            tmp *= tmp;
            n >>= 1;
        }
        return res;
    }
};

void Main() {
	using mint = ModInt<1000000007>;
	ll N, K; cin >> N >> K;
	// [l, r)
	auto sum = [](ll l, ll r) {
		return ((r - 1) * r / 2) - ((l - 1) * l / 2);
	};
	mint res = 0;
	for (ll i = K; i <= N + 1; ++i) {
		res += sum(N + 1 - i, N + 1) - sum(0, 0 + i) + 1;
	}
	cout << res.val << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3652