#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,k,ans;
  ans=0;
  cin>>n>>k;
  for(long i=k; i<=n+1; i++){
    ans=ans+1+(n+n-i+1)*i/2-i*(i-1)/2;
    ans=ans%1000000007;
  }
  cout<<ans;
}