#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = 0;
  for (long long i = 1; i <= m and i * i <= n; i++) {
    int d = n % i;
    ans += d;
    ans %= 1000000007;
  }
  long long d = sqrtl(n);
  d = n / d;
  for (long long i = d - 1; i >= 1; i--) {
    long long high = n / i;
    long long low = n / (i + 1);
    if (high >= m) {
      high = m;
      if (high <= low) break;
      long long t = (high % 1000000007 - low % 1000000007);
      t = (t + 1000000007) % 1000000007;
      t = t * (n % 1000000007);
      t %= 1000000007;
      high %= 1000000007;
      high = high * (high + 1) / 2;
      high %= 1000000007;
      low %= 1000000007;
      low = low * (low + 1) / 2;
      low %= 1000000007;
      ans += t - (i * (high - low)) % 1000000007;
      ans = (ans + 1000000007) % 1000000007;
      break;
    }
    long long t = (high % 1000000007 - low % 1000000007);
    t = (t + 1000000007) % 1000000007;
    t = t * (n % 1000000007);
    t %= 1000000007;
    high %= 1000000007;
    high = high * (high + 1) / 2;
    high %= 1000000007;
    low %= 1000000007;
    low = low * (low + 1) / 2;
    low %= 1000000007;
    ans += t - (i * (high - low)) % 1000000007;
    ans = (ans + 1000000007) % 1000000007;
  }
  if (m > n) {
    long long d = m - n;
    d %= 1000000007;
    n %= 1000000007;
    ans += (n * d) % 1000000007;
    ans %= 1000000007;
  }
  cout << ans << '\n';
}
