#include <iostream>

using namespace std;
#define ll long long
#define rp(i,start,end) for(ll i =start ; i<end; i++)


int main(){


ll N;
ll K;

ll sum =0;

cin >> N >> K;

rp(i,K,N+2){

    sum = sum +(N+1)*N/2 -(N-i)*(N-i+1)/2 - (i-1)*i/2 +1;
   

}


ll ans =sum%(1000000007);

cout << ans << endl;
return 0;






}


