#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
constexpr int MOD = 7 + 1000000000;
int add(int a, int b) {
  int ans = a + b;
  if (ans >= MOD) ans -= MOD;
  return ans;
}
int mul(int a, int b) { return (int)((1LL * a * b) % MOD); }
int fpow(int b, int e) {
  int ans = 1;
  for (; e; e >>= 1) {
    if (e & 1) ans = mul(ans, b);
    b = mul(b, b);
  }
  return ans;
}
const int inv = fpow(2, MOD - 2);
int solve(ll m, ll n) {
  ll s = 1;
  int ans = 0;
  while (s <= m) {
    ll q = n / s, r = n % s;
    ll k = 1 + (r / q);
    ll las = min(s + k - 1, m);
    ll len = 1 + las - s;
    assert(len >= 1);
    assert(((r - (len - 1) * q)) >= 0);
    int o = (((q % MOD) * ((len - 1) % MOD)) % MOD);
    int sum = mul(2, r % MOD) - o;
    if (sum < 0) sum += MOD;
    int lol = mul(len % MOD, mul(inv, sum));
    ans = add(ans, lol);
    s = 1 + las;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  if (m >= n) {
    ans = add(mul(n % MOD, (m - n) % MOD), solve(n - 1, n));
  } else {
    ans = solve(m, n);
  }
  cout << ans << '\n';
  return 0;
}
