unittest
{
	assert( [ "3 2" ].parse.expand.solve == 10 );
	assert( [ "200000 200001" ].parse.expand.solve == 1 );
	assert( [ "141421 35623" ].parse.expand.solve == 220280457 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	const M = 10L ^^ 9 + 7;
	auto as = iota( 0, n + 1 ).array;
	auto mi = as[ 0 .. k ].sum;
	auto ma = as[ $ - k .. $ ].sum;
	auto ans = ( ma - mi + 1 ) % M;
	foreach( i; k .. n + 1 )
	{
		mi += as[ i ];
		ma += as[ $ - i - 1 ];
		ans = ( ans + ma - mi + 1 ) % M;
	}
	return ans;
}
