#include <bits/stdc++.h>
using namespace std;
long long int mul(long long int a, long long int b) {
  return (a % 1000000007LL) * (b % 1000000007LL) % 1000000007LL;
}
long long int sum(long long int a, long long int b) {
  if (a > b) return 0;
  long long int f = a + b;
  long long int s = b - a + 1;
  if (f & 1)
    s >>= 1;
  else
    f >>= 1;
  return mul(f, s);
}
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int res = 0;
  long long int up = sqrt(n);
  up = min(up, m);
  for (long long int i = 1; i <= up; i++)
    res = (res + (n / i) * i) % 1000000007LL;
  for (long long int i = 1; i < up; i++) {
    long long int l = (n + i) / (i + 1);
    long long int r = n / (i);
    if (n % (i + 1) == 0) l++;
    if (l > m) continue;
    res = res + mul(i, sum(l, min(m, r)));
    res %= 1000000007LL;
    if (res < 0) res += 1000000007LL;
  }
  long long int l = (n + up) / (up + 1);
  long long int r = n / (up);
  if (n % (up + 1) == 0) l++;
  res = (res + mul(up, sum(max(up + 1, l), min(m, r)))) % 1000000007LL;
  long long int ans = (mul(n, m) - res + 1000000007LL) % 1000000007LL;
  cout << ans;
  return 0;
}
