#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define ff first
#define ss second
#define int long long 
#define endl "\n"
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	

const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
int a[N] ;
int n , k;

void solve(){
	cin >> n >> k;
	
	int sum  = 0;
	if(n+1==k)
	{	cout << "1" <<endl; return;}
	
	
	int lminsum = k*(k-1)/2;
	int rmaxsum = n*(n+1)/2   - (n-k)*(n-k+1)/2;
	int addr = n-k;
		
	sum = ( rmaxsum - lminsum + 1 ) % MOD;
	for(int i = k ; i<=n ; i++){
		lminsum += i;
		rmaxsum += addr;
		
		sum +=( rmaxsum - lminsum + 1 ) % MOD;
		addr --;
	}
	
	cout << sum % MOD <<endl;
}

int32_t main(){
	FAST;
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}