#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;

ll get(ll x) {
  if(x <= 0) return 0;
  return (x * (x + 1)) / 2ll;
}

int main() {
  ll n; cin >> n;
  ll k; cin >> k;
  ll p = 0;
  ll ans = 0;
  for(ll i = k; i <= n; i++) {
    ll L = get(i - 1);
    ll R = (get(n) - get(n - i) + MOD) % MOD;
    if(R < 0) R += MOD;
    //cout << L << ' ' << R << '\n';
    ll cur = (R - L + 1 + MOD) % MOD;
    if(cur < 0) cur += MOD;
    ans = (ans + cur) % MOD;
  }
  ans = (ans + 1) % MOD;
  cout << ans << '\n';
  
}