#include <bits/stdc++.h>
using namespace std;
long tousa(long a,long b){
  return b*(b+1)/2-a*(a-1)/2;
}

int main() {
  long N,K;cin>>N>>K;
  long wa=0;
  long mod=1000000007;
  for(long i=K;i<=N+1;i++){
    long x=tousa(N-i+1,N);
    long y=(i*(i-1)/2);
    //cout<<x<<" "<<y<<endl;
    wa+=(x-y+1)%mod;
    wa%=mod;
  }
  cout<<wa<<endl;
}