#include <bits/stdc++.h>
#pragma GCC optimize "trapv"
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T maxs(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T mins(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
long long inv2;
long long get(long long n) {
  n = n % 1000000007;
  return n * (n + 1) % 1000000007 * inv2 % 1000000007;
}
long long expo(long long first, long long second, long long p) {
  long long a = 1;
  first %= p;
  while (second) {
    if (second & 1) a = (a * first) % p;
    first = (first * first) % p;
    second /= 2;
  }
  return a;
}
long long solve() {
  long long n, m;
  cin >> n >> m;
  long long k = min(n, m);
  inv2 = expo(2, 1000000007 - 2, 1000000007);
  m = max(0LL, m - n) % 1000000007;
  long long nn = n % 1000000007;
  long long kk = k % 1000000007;
  long long val = (nn * kk % 1000000007 + m * nn % 1000000007) % 1000000007;
  for (long long i = 1, la; i <= k; i = la + 1) {
    la = min(k, n / (n / i));
    long long ans = (get(la) - get(i - 1) + 1000000007) % 1000000007;
    long long f = (n / i) % 1000000007;
    ans = ans * f % 1000000007;
    val = (val - ans) % 1000000007;
  }
  val = (val + 1000000007) % 1000000007;
  cout << val << "\n";
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
