// Reading stuff 
// check the modulus 
// for tree case n=1


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <vector> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
const ll hell=1000000007;
const ll mod=998244353;



int solve(){    
 
  int n,k;
  cin>>n>>k;

  int dp[n+2]={0};
  dp[0]=0;
  dp[1]=0;
  rep(i,2,n+2)dp[i]=(dp[i-1]+i-1+hell)%hell;

  int ans=0;

  rep(i,k,n+2)
  {  
     //cout<<dp[n+1]-dp[n-i+1]<<" "<<dp[i]<<endl;
     ans+=(dp[n+1]-dp[n-i+1]-dp[i]+1);
     ans+=2*hell;
     ans%=hell;
  }

  cout<<ans<<endl;


return 0;
}

 
signed main()
{    


   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);


int t=1;                                                                                                                  
//cin>>t;
int k=1;

    while(t--)
     {
      //cout<<"Case #"<<k<<": ";
      k++;
      solve();
     }
    return 0;
  }