#include <bits/stdc++.h>
const long long MOD = 1000000000 + 7;
const int N = 5e5 + 15;
const int maxn = 1e6 + 1000;
const int letter = 130;
const int INF = 1e17;
const double pi = acos(-1.0);
const double eps = 1e-8;
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long n, m;
long long md(long long x) { return x % MOD; }
int main() {
  cin >> n >> m;
  long long ans = 0, vs = 0;
  long long j;
  ans = md(md(n) * md(m));
  for (long long i = 1; i <= min(n, m); i++) {
    j = n / (n / i);
    if (j > m) j = m;
    long long pc;
    if ((i + j) & 1)
      pc = md(md((j - i + 1) / 2) * md(md(n / i) * md(i + j)));
    else
      pc = md(md(j - i + 1) * md(md(n / i) * md((i + j) / 2)));
    vs = vs + pc;
    vs = md(vs);
    i = j;
  }
  ans = md(ans - vs);
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}
