#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  int N, K;
  cin >> N >> K;
  ll maxs = 0, mins = 0;
  ll ans = 0;
  REP(i, N+1){
    mins += i;
    maxs += N-i;
    if(i+1 >= K){
      ans += maxs - mins + 1;
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}
