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