#include<bits/stdc++.h>
using namespace std;
long long n,k,ans=0,sum[2000010];
int main()
{
	cin>>n>>k;
	if (k>n){
		cout<<1<<endl;
		return 0;
	} 
	for (long long i=1;i<=2000000;i++) sum[i]=(sum[i-1]+i)%(1000000000+7);
	for (long long i=k;i<=n;i++){
		ans+=(sum[n]-sum[n-i]-sum[i-1]+1);
		ans%=(1000000000+7);
	}
	cout<<(ans+1)%(1000000000+7)<<endl;
	return 0;
}