#include <bits/stdc++.h>
using namespace std;
int const MAX_N = 1100;
long long const LL_INF = 1000000000000000000LL;
long long const MODULE = 1000000007LL;
long long gcd(long long a, long long b, long long &x, long long &y) {
  if (!a) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1, d;
  d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
long long find_inverse(long long a, long long module) {
  long long d, x, y;
  d = gcd(a, module, x, y);
  if (d != 1) return 0;
  return ((x % module) + module) % module;
}
long long TTT;
bool ok(long long mid, long long n, long long d) {
  if (mid >= d) return false;
  return n >= mid * mid + mid;
}
long long mega_F(long long n) {
  long long d = (long long)floor(sqrt(n + 0.0)) + 1;
  long long down = d - 1, up = n + 2, mid;
  while (up > down) {
    mid = (up + down) / 2;
    if (!ok(mid, n, d))
      up = mid;
    else
      down = mid + 1;
  }
  long long last_down = down;
  up = n + 2;
  while (up > down) {
    mid = (up + down) / 2;
    if (n / last_down - n / mid < mid - last_down)
      up = mid;
    else
      down = mid + 1;
  }
  return down - 1;
}
long long calc_to_n_fast_2(long long n, long long max_dv) {
  if (n <= 2) return 0;
  long long ans = 0;
  ans = n % MODULE;
  ans = ans * (max_dv % MODULE);
  ans %= MODULE;
  long long sum = 0;
  long long bg = 1, en = 1, down, up, QQ, mid;
  long long FIRST_SECOND = mega_F(n);
  while (bg <= max_dv) {
    if (bg < FIRST_SECOND) {
      en = bg + 1;
    } else {
      down = en;
      up = max_dv + 1;
      QQ = n / bg;
      while (up > down) {
        mid = (up + down) / 2;
        if (n / mid < QQ)
          up = mid;
        else
          down = mid + 1;
      }
      en = down;
    }
    long long cur_count = (en - bg) % MODULE;
    long long cur_value = (n / bg) % MODULE;
    long long cur_minimal = ((cur_count * cur_value) % MODULE * (bg % MODULE));
    long long one_bl = (((((cur_count - 1) * cur_count) % MODULE) * (TTT)) %
                        MODULE * cur_value);
    sum = (sum + one_bl + cur_minimal) % MODULE;
    bg = en;
  }
  ans = (ans - sum) % MODULE;
  return (((ans % MODULE) + MODULE) % MODULE);
}
long long solve(long long n, long long m) {
  if (n < m) {
    long long ans = calc_to_n_fast_2(n, n) % MODULE;
    ans = (ans + (((m - n) % MODULE) * (n % MODULE))) % MODULE;
    return (((ans % MODULE) + MODULE) % MODULE);
  } else if (n == m) {
    long long ans = calc_to_n_fast_2(n, n) % MODULE;
    return (((ans % MODULE) + MODULE) % MODULE);
  } else {
    long long ans = calc_to_n_fast_2(n, m) % MODULE;
    return (((ans % MODULE) + MODULE) % MODULE);
  }
}
long long solve_slow(long long n, long long m) {
  long long ans = 0;
  for (int i = 1; i <= m; i++) ans += n % i;
  return (((ans % MODULE) + MODULE) % MODULE);
}
int main() {
  TTT = find_inverse(2, MODULE) % MODULE;
  long long n, m;
  cin >> n >> m;
  cout << solve(n, m);
  return 0;
}
