#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N,K;
  cin>>N>>K;
  vector<ll>sum(N+1,0);
  for(int i=1;i<=N;i++)sum[i]+=(i+sum[i-1])%MOD;
  ll ans=0;
  for(int i=K-1;i<=N;i++){
    if(i==N)ans++;
    else ans=((ans+sum[N]-sum[N-i-1]-sum[i]+1)%MOD+MOD)%MOD;
  }
  cout<<ans<<endl;
  return 0;
}
