#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        "\n"
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  int n,k;
  cin>>n>>k;
  ll sum=0;
  ll min=0;
  	for(int i=0;i<k;i++)
  	min+=i;
  ll max=0;
	  for(int i=n;i>n-k;i--)
  	   max+=i;
  	sum=max-min+1;
  	k++;
  while(k<=n+1)
  {
  	
    
	  min+=k-1; 	
      max+=n-k+1;
  	sum+=max-min+1;
  	   sum%=mod;
   k++;
   } 
  
cout<<sum<<endl;

}