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