Problem:
Score : 400 points

Problem Statement

We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.

We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Constraints

1 \leq N \leq 2\times 10^5

1 \leq K \leq N+1

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of possible values of the sum, modulo (10^9+7).

Sample Input 1

3 2

Sample Output 1

10

The sum can take 10 values, as follows:

(10^{100})+(10^{100}+1)=2\times 10^{100}+1

(10^{100})+(10^{100}+2)=2\times 10^{100}+2

(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\times 10^{100}+3

(10^{100}+1)+(10^{100}+3)=2\times 10^{100}+4

(10^{100}+2)+(10^{100}+3)=2\times 10^{100}+5

(10^{100})+(10^{100}+1)+(10^{100}+2)=3\times 10^{100}+3

(10^{100})+(10^{100}+1)+(10^{100}+3)=3\times 10^{100}+4

(10^{100})+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+5

(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+6

(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\times 10^{100}+6

Sample Input 2

200000 200001

Sample Output 2

1

We must choose all of the integers, so the sum can take just 1 value.

Sample Input 3

141421 35623

Sample Output 3

220280457

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

// fahadmd16(IIEST Shibpur)

#include<bits/stdc++.h>
#include <algorithm>
using namespace std;

#define ll                          long long
#define pb                          push_back
#define pf                          push_front
#define eb                          emplace_back
#define mp                          make_pair
#define ff                          first
#define ss                          second
#define db                          double
#define pll                         pair<ll, ll>
#define ALL(a)                      (a).begin(),(a).end()
#define endl                        "\n"

#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define ford(i, n) for (ll i = n - 1; i >= 0; i--)
#define forab(i, a, b) for(ll i = a; i < b; i++)
#define eps 1e-10

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)


#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;


const ll sz = 2e5 + 3;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9;


typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;

ll power(ll n, ll k, ll m) {
    ll ans = 1;
    while (k) {
        if (k & 1)ans = (ans * n) % m;
        k /= 2;
        n = (n * n) % m;
    }
    return ans;
}

void solver() {
    ll n, k; cin >> n >> k;
    ll a[n + 1];
    forn(i, n + 1)a[i] = i;
    VL pref(n + 2), suff(n + 2);
    pref[0] = 0;
    forn1(i, n + 2)pref[i] = pref[i - 1] + a[i - 1];
    suff[n + 1] = 0;
    ford(i, n + 1)suff[i] = suff[i + 1] + a[i];

    // trace(pref);
    // trace(suff);
    ll ans = 0;
    forab(i, k, n + 2) {
        ll min = pref[i] - pref[0];
        ll max = suff[n + 1 - i] - suff[n + 1];
        // trace3(min, max, i);
        ans += (max - min + 1);
        ans %= mod;
    }
    cout << ans << endl;
}


int main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    IOS;
    ll T = 1; //cin >> T;
    forn1(i, T + 1) {
        clock_t z = clock();
        solver();
        debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
    }
    return 0;
}