#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define debug(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
#define INF 1e+8
#define PI acos(-1)
#define TAU PI * 2
using ll = long long;
using ull = unsigned long long;
const ll MOD = 1000000007;

int main(){
    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    for(ll i = k; i <= n + 1; ++i){
        ll left = i * (i - 1) / 2;
        ll right = (2 * n - i + 1) * i / 2;
        ll add = right - left + 1;
        ans = (ans + add) % MOD;
    }

    println(ans);
}