#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long ppow(long long a, long long p) {
  if (p == 0) return 1;
  long long r = ppow(a, p / 2LL) % MOD;
  if (p % 2LL == 0)
    return (r * r) % MOD;
  else
    return (((r * r) % MOD) * a) % MOD;
}
long long solve(long long n, long long m) {
  long long lel = ppow(2LL, MOD - 2LL);
  long long res = 0;
  if (n < m) {
    res += (n % MOD) * ((m - n) % MOD);
    res %= MOD;
    m = n;
  }
  if (m == 1) return res;
  long long sm = 0;
  long long ppr = m;
  long long cnt = 0;
  while (1) {
    long long cur = (n / ppr);
    long long nnx = n / (cur + 1LL);
    long long nx = nnx % MOD;
    cnt++;
    long long pr = ppr % MOD;
    long long cc = cur % MOD;
    sm += ((cc *
            ((MOD + (pr * (pr + 1LL)) % MOD - (nx * (nx + 1LL)) % MOD) % MOD)) %
           MOD) *
          lel;
    sm %= MOD;
    if (nnx > ppr) {
      cout << "cur = " << cur << endl;
      cout << "ppr = " << ppr << endl;
      cout << "nnx = " << nnx << endl;
      cout << "ppr = " << ppr << endl;
      break;
    }
    if (nnx == 1) {
      sm += n % MOD;
      sm %= MOD;
      break;
    }
    ppr = nnx;
  }
  sm = ((n % MOD) * (m % MOD)) % MOD - sm;
  sm = (sm + MOD) % MOD;
  return (sm + res) % MOD;
}
int main() {
  ios::sync_with_stdio(0);
  long long n, m;
  cin >> n >> m;
  cout << solve(n, m);
}
