#include<iostream>
using ll = long long;
const int MOD = 1000000007;
int main()
{
  int n,k;
  std::cin>>n>>k;
  ll res = ((n * (n + 1) % MOD * (n + 2) % MOD + k * (k - 1) % MOD * (2 * k - 3 * n - 4) % MOD) % MOD * modInverse(6) % MOD + n - k + 2) % MOD;
  std::cout<<res<<std::endl
}

ll modInverse(ll x) {
  return pow(x, mod - 2)
}

ll pow(ll x, ll n) {
    ll mod = MOD;
    ll res = 1;
    while (n > 0) {
        if (n % 2 == 1) res = res * x % mod;
        x = x * x % mod;
        n = n / 2;
    }
    return res;
}