#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long multMod(long long a, long long b) {
  if (b == 1ll) return a % MOD;
  long long x = multMod(a, b / 2ll);
  x += x;
  if (x > MOD) x -= MOD;
  if (b % 2ll) {
    x += a % MOD;
    if (x > MOD) x -= MOD;
  }
  return x;
}
int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = 0;
  if (m > n) ans += multMod(n, m - n);
  m = min(n, m);
  long long mn = 0;
  for (long long i = 1; i * i <= n && i <= m; ++i) {
    ans = (ans + n % i) % MOD;
    mn = i;
  }
  for (long long k = 1; k * k <= n; ++k) {
    long long lg = n / (k + 1) + 1, rg = n / k;
    lg = max(lg, mn + 1);
    rg = min(rg, m);
    if (rg < lg) continue;
    long long md1 = n % rg, md2 = n % lg;
    if ((md1 + md2) % 2ll == 0) {
      ans += multMod((md1 + md2) / 2ll, rg - lg + 1);
    } else {
      ans += multMod(md1 + md2, (rg - lg + 1) / 2ll);
    }
    ans %= MOD;
  }
  cout << ans;
  return 0;
}
