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

int main(){
  const int64_t mod=1e9+7;
  int N,K;
  cin >> N >> K;
  vector<int64_t> sum(N+2);
  sum.at(0)=0;
  for(int i=1;i<=N+1;i++){
    sum.at(i)=i-1+sum.at(i-1);
  }
  int64_t ans=0;
  for(int i=K;i<=N+1;i++){
    ans+=(sum.at(N+1)-sum.at(N+1-i))-(sum.at(i)-sum.at(0))+1;
    ans%=mod;
  }
  cout << ans << endl;
  return 0;
}
