#include<iostream>
using namespace std;
const int mod=1e9+7; 
int main(){
	long long res=0;
	long long n,k;
	cin>>n>>k;
	
	while(k<=n+1){
		long long qian=((k-1)*k/2)%mod,hou=((2*n%mod-k%mod+1)*k/2)%mod;
		res=(res+hou-qian+1+mod)%mod;
		k++;
	} 
	cout<<res;
} 