#include <bits/stdc++.h>
using namespace std;
const int Mod = 1e9 + 7;
int main() {
  long long N, M, ans = 0, Last = 0;
  scanf("%I64d%I64d", &N, &M);
  long long Min = min(N, M);
  for (long long i = 1, j; i <= Min; i = j + 1) {
    j = min(N / (N / i), M);
    long long tmp;
    if (j & 1LL)
      tmp = ((j + 1) / 2 % Mod) * (j % Mod) % Mod;
    else
      tmp = (j / 2 % Mod) * ((j + 1) % Mod) % Mod;
    ans =
        (ans + (N / i) % Mod * (((tmp - Last) % Mod + Mod) % Mod) % Mod) % Mod;
    Last = tmp;
  }
  ans = (((N % Mod) * (M % Mod) - ans) % Mod + Mod) % Mod;
  printf("%I64d", ans);
  return 0;
}
