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)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

//a^b(mod 1000000007)
ll mod_pow(ll a, ll b){
 ll m= 1000000007;
 if(b == 0) return 1;
 if(b % 2 == 0){
   ll d = mod_pow(a,b/2);
   return (d*d)%m;
 }else return a%m*mod_pow(a,b-1)%m;
}

//nCr(mod 100000007)
//O(nlog(mod))
ll mod_comb(ll n,ll r){
 ll m=1000000007;
 if(r > n) return 0;
 if(n == r || r == 0) return 1;
 ll f1 = 1,f2 = 1;
 for(ll i = n; i >= n-r+1; i--) f1 = f1*i%m;
 for(ll i = r; i >= 1; i--) f2 = f2*i%m;
 return f1*mod_pow(f2,m-2)%m;
}

int main() {

  ll n,k, count=0, ans=0;
 
  cin >> n;
  cin >> k ;
  ll mod = 1000000007;

  for(ll i = k; i<=n+1; i++){
    ll left=0, right=0;
    left=i*(i-1)/2;
    
    if(n-i>=0){
      right=(n)*(n+1)/2 - (n-i)*(n-i+1)/2;
    }
    else {
      right=(n)*(n+1)/2;
    }
    ans+=(right-left+1)%mod;
  }


  cout << ans%mod << endl;
}