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 Lua (LuaJIT 2.1.0) (judge verdict: Accepted)

local ffi=require"ffi"
local modint
do
local MOD=1000000007
local mt={}
modint=setmetatable({new=function(x)return setmetatable({v=x},mt)end},{__call=function(o,x)return setmetatable({v=x%MOD},mt)end})
local function add(a,b)return (a+b)%MOD end
function mt.__add(a,b) return modint.new(add(a.v,b.v))end
local function sub(a,b)return (a-b)%MOD end
function mt.__sub(a,b) return modint.new(sub(a.v,b.v))end
local function mul(a,b)
	local ret=0
	while(b>0)do
		if(b%2==1)then ret=(ret+a)%MOD end
		a=(a+a)%MOD
		b=math.floor(b*.5)
	end
	return ret
end
function mt.__mul(a,b)
	a=a.v b=b.v
	return modint(a<b and mul(b,a)or mul(a,b))
end
local function pow(a,b)
	local ret=1
	while(b>0)do
		if(b%2==1)then ret=mul(ret,a)end
		a=mul(a,a)
		b=math.floor(b*.5)
	end
	return ret
end
function mt.__pow(a,b)return modint(pow(a.v,b.v))end
local function inv(x)
local a=x
local b,u,v=MOD,1,0
repeat
local t=math.floor(a/b)
a,b=b,a-t*b
u,v=v,u-t*v
until(b==0)
return u
end
local function div(a,b)return mul(a,inv(b))end
function mt.__div(a,b)return modint.new(div(a.v,b.v))end
function mt.__tostring(x)return tostring(x.v)end
local method={}
mt.__index=method
function method.inv(x)return modint.new(inv(x.v))end
do
local MAX=510000
local ct=ffi.typeof("int[$]",MAX)
local fac=ffi.new(ct,{1,1})
local inv=ffi.new(ct,{1,1})
local finv=ffi.new(ct,{1,1})
for i=2,MAX-1 do
fac[i]=mul(fac[i-1],i)
inv[i]=MOD-mul(inv[MOD%i],math.floor(MOD/i))
finv[i]=mul(finv[i-1],inv[i])
end
function method.C(n,k)
n=n.v k=k.v
if(n<k)then return 0 end
return mul(mul(finv[k],finv[n-k]),fac[n])
end
end
end --modint define

N=io.read"*n"
K=io.read"*n"

r=modint(0)
for i=K,N+1 do
local min=i*(i-1)/2
local max=(N-i+1+N)*i/2
r=r+modint(max-min+1)
end
print(r)