#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  ll mod=1e9+7;
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  for(ll i=k;i<=n+1;i++){
    ans+=((2*n-i+1)*i)/2;
    ans%=mod;
    ans-=(i*(i-1))/2;
    ans%=mod;
    ans++;
    ans%=mod;
  }
  if(ans<0){
    ans+=mod;
  }
  cout<<ans<<endl;
}