#include <bits/stdc++.h>
using namespace std;
 
 
	 
int main() {
  	int N,K;
  	cin >> N >>K;
	int answer;
  	answer = ((N+1)*(N*N+2N+6)-(K-1)*(-2*K*K+(4+3*N)*K+6));
  	int a;
  	a = answer / 6;
  	
  	cout << a%(pow(10,9)+7) << endl;
  
}