#include<iostream>
using namespace std;
int p = 1000000007;
int main()
{
  long long n,k,t,i,res=0;
  cin >> n >> k;
  for(i=k;i<=n+1;i++){
    res+=(n-i+1)*i+1;
    res%=p;
  }
  cout << res << endl;
  return 0;
}