#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<class T> inline bool chmin(T& a, T b) {
        if (a > b) {
            a = b;
            return true;
        }
        return false;
    }
    template<class T> inline bool chmax(T& a, T b) {
        if (a < b) {
            a = b;
            return true;
        }
        return false;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    template<int MOD> struct Fp {
        long long val;
        constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
            if (val < 0) val += MOD;
        }
        constexpr int getmod() { return MOD; }
        constexpr Fp operator - () const noexcept {
            return val ? MOD - val : 0;
        }
        constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
        constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
        constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
        constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
        constexpr Fp& operator += (const Fp& r) noexcept {
            val += r.val;
            if (val >= MOD) val -= MOD;
            return *this;
        }
        constexpr Fp& operator -= (const Fp& r) noexcept {
            val -= r.val;
            if (val < 0) val += MOD;
            return *this;
        }
        constexpr Fp& operator *= (const Fp& r) noexcept {
            val = val * r.val % MOD;
            return *this;
        }
        constexpr Fp& operator /= (const Fp& r) noexcept {
            long long a = r.val, b = MOD, 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 % MOD;
            if (val < 0) val += MOD;
            return *this;
        }
        constexpr bool operator == (const Fp& r) const noexcept {
            return this->val == r.val;
        }
        constexpr bool operator != (const Fp& r) const noexcept {
            return this->val != r.val;
        }
        friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
            return os << x.val;
        }
        friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
            if (n == 0) return 1;
            auto t = modpow(a, n / 2);
            t = t * t;
            if (n & 1) t = t * a;
            return t;
        }
    };
    
    using mint = Fp<1000000007>;

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,k;
        cin>>n>>k;
        mint ans=0;
        rep2(i,k,n+2){
            mint res=i*(n+1-i)+1;
            ans+=res;
        }
        cout<<ans<<endl;
    }

Measured memory_bytes: 3640