#include <bits/stdc++.h>
using namespace std;
const long long int md = 1e9 + 7;
long long int n, m, ans = 0;
vector<long long int> v;
long long int pw(long long int b) {
  if (b == 0) return 1ll;
  if (b % 2 == 1) return (((pw(b / 2) * pw(b / 2)) % md) * 2ll) % md;
  return ((pw(b / 2) * pw(b / 2)) % md);
}
long long int doinv(long long int a, long long int b) {
  b = pw(1e9 + 5);
  b %= md;
  a *= b;
  a %= md;
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  long long int s = 1, t, k;
  while (s < n) {
    k = n / s;
    t = n / k;
    v.push_back(s);
    s = t + 1;
  }
  for (int i = 0; i < (int)v.size(); i++) {
    s = v[i], k = n / s, t = n / k;
    if (s > m) break;
    t = min(t, m);
    long long int m1 = n % s, m2 = n % t;
    long long int tmp = (m1 + m2), t2 = t - s + 1;
    tmp %= md;
    t2 %= md;
    tmp = (tmp * t2) % md;
    ans = (ans + tmp) % md;
  }
  ans = doinv(ans, 2ll);
  if (m > n) {
    long long int tmp = ((n % md) * ((m - n) % md)) % md;
    ans += tmp;
    ans %= md;
  }
  cout << ans << endl;
  return 0;
}
