#include <bits/stdc++.h>
using namespace std;
const long long MAGIC = 3162277;
const long long BASE = 1e9 + 7;
long long Add(long long &a, long long b) {
  long long q = (a + b) % BASE;
  if (q < 0) q += BASE;
  return q;
}
long long sum(long long n) {
  long long x = (n & 1) ? n : n / 2;
  long long y = (n & 1) ? (n + 1) / 2 : n + 1;
  return (x % BASE) * (y % BASE) % BASE;
}
long long sum(long long l, long long r) {
  long long ans = sum(r);
  ans = Add(ans, -sum(l - 1));
  return ans;
}
long long FindMax(long long n, long long q) { return n / q; }
long long FindMin(long long n, long long q, long long lim) {
  long long l = 1, r = lim, f = -1;
  while (l <= r) {
    long long m = (l + r) >> 1;
    long long rr = n - q * m;
    if (rr < m) {
      f = m;
      r = m - 1;
    } else
      l = m + 1;
  }
  return f;
}
long long Solve(long long n, long long m) {
  long long ans = 0, length = 0;
  for (long long i = 1; i <= min(MAGIC, m); ++i) ans = Add(ans, n % i);
  for (long long q = 1; q <= MAGIC + 2; ++q) {
    long long r = min(m, FindMax(n, q));
    long long rr = n - q * r;
    if (rr >= m) continue;
    long long l = max(MAGIC + 1, FindMin(n, q, r));
    if (r - l + 1 <= 0) continue;
    length += r - l + 1;
    long long val = (n % BASE) * ((r - l + 1) % BASE);
    val = Add(val, -q * sum(l, r) % BASE);
    ans = Add(ans, val);
  }
  assert(length + min(MAGIC, m) == m);
  return ans;
}
int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = Solve(n, min(n, m));
  if (m > n) ans = Add(ans, ((m - n) % BASE) * (n % BASE) % BASE);
  cout << ans << endl;
  return 0;
}
