#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    for (ll i = K; i <= N+1; i++) {
        ll l = (i - 1) * i / 2;
        ll r = (2 * N - i + 1) * i / 2;
        ans += (r - l) + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}
