#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) cout << (#x) <<"="<< x << endl;
#define bug2( x , y ) cout << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;
#define bug3( x , y , z ) cout << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;
#define bug4( x , y , z , w) cout << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;
#define bugn( x , n ){ cout<<(#x)<<":";for(int i=0;i<n;i++)cout<<(#x)<<"["<<i<<"]:"<< x[i] << "    "; cout<<endl;}
#define bugnm( x , n , m ){ cout<<(#x)<<endl;for(int i=0;i<n;i++){ cout<<"Row #"<<i<<":"; for(int j=0;j<m;j++) cout<<x[i][j]<<"     "; cout << endl;}}
using namespace std;	


const int MOD = 1e9+7;
int RangeSum(int n){
	return n * ( n + 1)/2;
}
int32_t main()
{
    IOS
    int n,k;cin>>n>>k;
    int ans = 0;
    for(int i=k;i<=n+1;i++){
		int minsum =  RangeSum(i-1);
		int maxsum =  RangeSum(n) - RangeSum(n-i);
		minsum%=MOD;
		maxsum%=MOD;
		ans+=  ( maxsum - minsum + 1 +MOD )%MOD;
		ans%= MOD;
		//bug3(i,minsum,maxsum);
	}
	cout << ans << endl;
   
}

				
			
	

	
			
	
	
	
	
	

	

	

	
		
