#include <bits/stdc++.h>
using namespace std;
const int maxN = 500010, modP = 1e9 + 7;
long long res, n, m;
long long getSum(long long x) {
  long long temp1 = x;
  long long temp2 = x + 1;
  if (temp1 % 2)
    temp2 /= 2;
  else
    temp1 /= 2;
  return ((temp1 % modP) * (temp2 % modP)) % modP;
}
int main() {
  cin >> n >> m;
  res = 0;
  for (int i = 1; i <= int(sqrt(n)); ++i) {
    if (i <= m) res = (res + (n % i)) % modP;
    long long tmp = int(sqrt(n)) + 1;
    long long l = max(tmp, (n / (i + 1)) + 1), r = min(m, n / i);
    if (l > r) continue;
    long long temp1 = ((n % modP) * ((r - l + 1) % modP)) % modP;
    long long temp2 = getSum(r);
    long long temp3 = getSum(l - 1);
    temp2 = (((temp2 - temp3) % modP) + modP) % modP;
    temp2 = (temp2 * i) % modP;
    temp1 = ((temp1 - temp2) % modP + modP) % modP;
    res = (res + temp1) % modP;
  }
  long long resT = 0;
  if (m > n) res = (res + (((n % modP) * ((m - n) % modP)) % modP)) % modP;
  cout << res;
}
