	#include<bits/stdc++.h>
	using namespace std;
	#define fo(i,n) for(int i=0;i<n;i++)
	#define pb push_back
	#define mp map<int,int>
	#define ump unordered_map<int,int>
	#define vi vector<int>
	#define M INT_MAX
	#define MI INT_MIN
	#define ll long long int
	#define pii pair<int,int>
	#define F first
	#define S second
	#define fall(i,a,b) for(int i=a;i<b;i++)
	#define pi 3.1415926535
	ll MOD=1e9+7;
	void solve()
	{
			ll n,k,ans=0;
			cin>>n>>k;
                  
			ll arr[n+10];
			arr[0]=0;
			for(int i=1;i<=(n+1);i++)
			arr[i]=arr[i-1]+i;

			for(int i=k;i<=(n+1);i++)
			{
				ll mini=arr[i];
				ll maxi=arr[n+1]-arr[n-i+1];
				ans+=(maxi-mini+1);
				ans%=MOD;
			}
			cout<<ans<<endl;
	}
	int main()
	{
		ios_base::sync_with_stdio(false);
	      cin.tie(NULL);
		solve();
	}