#include <bits/stdc++.h>
using namespace std;
const int lmt = 10000000;
long long power(long long a, long long b) {
  long long id = 1;
  while (b > 0) {
    if (b & 1LL) id = ((id % 1000000007) * (a % 1000000007)) % 1000000007;
    a = ((a % 1000000007) * (a % 1000000007)) % 1000000007;
    b = b >> 1LL;
  }
  return id;
}
long long brute(long long n, long long m) {
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    ans += (n % i);
    ans %= 1000000007;
  }
  return ans;
}
long long getAPSum(long long a, long long n, long long d) {
  long long ans = 2LL * a;
  ans %= 1000000007;
  long long loc = (((n - 1LL) % 1000000007) + 1000000007) % 1000000007;
  loc = ((loc % 1000000007) * (d % 1000000007)) % 1000000007;
  ans += loc;
  ans = ((ans % 1000000007) + 1000000007) % 1000000007;
  ans = ((ans % 1000000007) * (n % 1000000007)) % 1000000007;
  ans *= power(2, 1000000007 - 2);
  ans %= 1000000007;
  return ans;
}
int main() {
  long long n, m;
  cin >> n >> m;
  long long cur = m;
  long long ans = 0;
  if (m > n) {
    long long loc = (((m - n) % 1000000007) + 1000000007) % 1000000007;
    loc = ((loc % 1000000007) * (n % 1000000007)) % 1000000007;
    loc %= 1000000007;
    ans += loc;
    ans %= 1000000007;
    cur = n;
  }
  while (cur > lmt) {
    long long d = n / cur;
    long long a = n % cur;
    long long nn = cur - (n / (d + 1));
    ans += getAPSum(a, nn, d);
    ans %= 1000000007;
    cur = n / (d + 1);
  }
  ans += brute(n, cur);
  ans %= 1000000007;
  printf("%lld\n", ans);
  return 0;
}
