#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<N; i++)
#define lint long long
#define square_vector(name,N,M) vector<vector<lint>>name(N,vector<lint>(M,0))
#define sort(V) sort(V.begin(),V.end())

int main() {
  lint N,K;
  cin >> N >> K;
  lint ans = 0;
  lint mod = 1000000007;
  lint term = 1;
  for (lint i=1; i<N+2; i++) {
    term += N;
    term += mod;
    term -= (i-1)*2;
    term %= mod;
    if (i >= K) {
      ans += term;
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}