#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n, m, ans;
long long mul(long long a, long long k) {
  long long ans = 0;
  a %= mod, k %= mod;
  while (k) {
    if (k & 1) ans = (ans + a) > mod ? ans + a - mod : ans + a;
    a = (a << 1) > mod ? (a << 1) - mod : (a << 1);
    k >>= 1;
  }
  return ans;
}
int main() {
  cin >> n >> m;
  ans = mul(n, m);
  for (long long l = 1, r; l <= n; l = r + 1) {
    r = n / (n / l);
    if (m < r) {
      ans -= mul(mul(mul(m + l, m - l + 1), 500000004), n / l);
      while (ans < 0) ans += mod;
      break;
    }
    ans -= mul(mul(mul(r + l, r - l + 1), 500000004), n / l);
    while (ans < 0) ans += mod;
  }
  cout << ans;
  return 0;
}
