#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long n, m;
void add(int &n, const int &b) {
  n += b;
  if (n >= MOD) n -= MOD;
}
int mul(long long a, long long b) { return 1LL * (a % MOD) * (b % MOD) % MOD; }
int sub(int a, int b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
int pw(int cs, int sm) {
  if (sm == 0) return 1;
  int hpw = pw(cs, sm >> 1);
  hpw = 1LL * hpw * hpw % MOD;
  if (sm & 1) hpw = 1LL * hpw * cs % MOD;
  return hpw;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  int res = 0;
  if (m > n) {
    add(res, 1LL * (n % MOD) * ((m - n) % MOD) % MOD);
    m = n;
  }
  int rt = sqrt(n), i2 = pw(2, MOD - 2);
  for (int i = 1; i <= m && n / i > rt; ++i) add(res, n % i);
  for (int i = rt; i >= 1; --i) {
    long long c = n / (i + 1) + 1, mod = n % c, x = mod / i;
    if (n / i >= m) {
      if (1LL * i * (m + 1) <= n) {
        long long nw_mod = n % (1LL * i * (m + 1));
        long long nwx = (mod - nw_mod) / i - 1;
        if (nwx >= 0)
          add(res, sub(mul(mod, nwx + 1), mul(i, mul(mul(nwx, nwx + 1), i2))));
      } else
        add(res, sub(mul(mod, x + 1), mul(i, mul(mul(x, x + 1), i2))));
      break;
    }
    add(res, sub(mul(mod, x + 1), mul(i, mul(mul(x, x + 1), i2))));
  }
  cout << res;
  return 0;
}
