#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int mul(long long a, long long b) {
  a %= mod;
  b %= mod;
  return a * b % mod;
}
int add(long long a, long long b) {
  a %= mod;
  b %= mod;
  return (a + b) % mod;
}
int sum(long long k) { return mul(mul(k, add(k, 1)), (mod + 1) / 2); }
int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = 0;
  if (m <= 3162300) {
    for (int i = 1; i <= m; ++i) ans = add(ans, n % i);
    return cout << ans << endl, 0;
  }
  for (long long i = 1; i * i <= n; ++i) {
    long long k = n / i;
    long long delta = n % i;
    long long dt = delta / k;
    long long h = (k - delta - 1) / (i + 1);
    long long lans = add(mul(i, dt + 1), sum(dt));
    lans = mul(k, lans);
    ans = add(ans, lans);
    if (i < k) {
      bool ok = 1;
      if (m < k) {
        if (n / m == n / k) {
          k = m;
          delta = n % m;
          h = (m - delta - 1) / (i + 1);
        } else
          ok = 0;
      }
      if (ok) {
        lans = add(mul(k, h + 1), mod - sum(h));
        lans = mul(i, lans);
        ans = add(ans, lans);
      }
    }
    i += dt;
  }
  ans = add(mul(n, m), mod - ans);
  cout << ans << endl;
  return 0;
}
