#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long fast_power(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % 1000000007;
    b >>= 1;
    a = (a * a) % 1000000007;
  }
  return ans;
}
long long sb = fast_power(2, 1000000007 - 2);
long long f(long long n, long long m) {
  long long ans = (n % 1000000007) * (m % 1000000007) % 1000000007;
  long long sqn = (long long)sqrt(n);
  long long blo = n / sqn;
  for (long long i = 1; i <= min(blo, m); i++) {
    ans = ans - n / i * i;
    ans = ((ans) - (ans) / (1000000007) * (1000000007));
  }
  if (m > blo) {
    long long x = n / m + 1;
    ans =
        ((ans -
          (((((((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) -
               ((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) /
                   (1000000007) * (1000000007))) -
             ((((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) -
               ((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) /
                   (1000000007) * (1000000007))) /
                 (1000000007) * (1000000007)) *
            (x - 1)) -
           ((((((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) -
               ((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) /
                   (1000000007) * (1000000007))) -
             ((((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) -
               ((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) /
                   (1000000007) * (1000000007))) /
                 (1000000007) * (1000000007)) *
            (x - 1)) /
               (1000000007) * (1000000007))) -
         (ans -
          (((((((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) -
               ((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) /
                   (1000000007) * (1000000007))) -
             ((((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) -
               ((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) /
                   (1000000007) * (1000000007))) /
                 (1000000007) * (1000000007)) *
            (x - 1)) -
           ((((((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) -
               ((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) /
                   (1000000007) * (1000000007))) -
             ((((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) -
               ((((((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) -
                  (((((n / x + 1) + (m)) -
                     ((n / x + 1) + (m)) / (1000000007) * (1000000007))) *
                   ((((m) - (n / x + 1) + 1) -
                     ((m) - (n / x + 1) + 1) / (1000000007) * (1000000007)))) /
                      (1000000007) * (1000000007)) *
                 sb)) /
                   (1000000007) * (1000000007))) /
                 (1000000007) * (1000000007)) *
            (x - 1)) /
               (1000000007) * (1000000007))) /
             (1000000007) * (1000000007));
    for (long long i = x + 1; i <= sqn; i++)
      ans = ((ans - (((((((((n / i + 1) + (n / (i - 1))) -
                           ((n / i + 1) + (n / (i - 1))) / (1000000007) *
                               (1000000007))) *
                         ((((n / (i - 1)) - (n / i + 1) + 1) -
                           ((n / (i - 1)) - (n / i + 1) + 1) / (1000000007) *
                               (1000000007)))) -
                        (((((n / i + 1) + (n / (i - 1))) -
                           ((n / i + 1) + (n / (i - 1))) / (1000000007) *
                               (1000000007))) *
                         ((((n / (i - 1)) - (n / i + 1) + 1) -
                           ((n / (i - 1)) - (n / i + 1) + 1) / (1000000007) *
                               (1000000007)))) /
                            (1000000007) * (1000000007)) *
                       sb)) -
                     ((((((((n / i + 1) + (n / (i - 1))) -
                           ((n / i + 1) + (n / (i - 1))) / (1000000007) *
                               (1000000007))) *
                         ((((n / (i - 1)) - (n / i + 1) + 1) -
                           ((n / (i - 1)) - (n / i + 1) + 1) / (1000000007) *
                               (1000000007)))) -
                        (((((n / i + 1) + (n / (i - 1))) -
                           ((n / i + 1) + (n / (i - 1))) / (1000000007) *
                               (1000000007))) *
                         ((((n / (i - 1)) - (n / i + 1) + 1) -
                           ((n / (i - 1)) - (n / i + 1) + 1) / (1000000007) *
                               (1000000007)))) /
                            (1000000007) * (1000000007)) *
                       sb)) /
                         (1000000007) * (1000000007)) *
                        (i - 1)) -
             (ans - (((((((((n / i + 1) + (n / (i - 1))) -
                           ((n / i + 1) + (n / (i - 1))) / (1000000007) *
                               (1000000007))) *
                         ((((n / (i - 1)) - (n / i + 1) + 1) -
                           ((n / (i - 1)) - (n / i + 1) + 1) / (1000000007) *
                               (1000000007)))) -
                        (((((n / i + 1) + (n / (i - 1))) -
                           ((n / i + 1) + (n / (i - 1))) / (1000000007) *
                               (1000000007))) *
                         ((((n / (i - 1)) - (n / i + 1) + 1) -
                           ((n / (i - 1)) - (n / i + 1) + 1) / (1000000007) *
                               (1000000007)))) /
                            (1000000007) * (1000000007)) *
                       sb)) -
                     ((((((((n / i + 1) + (n / (i - 1))) -
                           ((n / i + 1) + (n / (i - 1))) / (1000000007) *
                               (1000000007))) *
                         ((((n / (i - 1)) - (n / i + 1) + 1) -
                           ((n / (i - 1)) - (n / i + 1) + 1) / (1000000007) *
                               (1000000007)))) -
                        (((((n / i + 1) + (n / (i - 1))) -
                           ((n / i + 1) + (n / (i - 1))) / (1000000007) *
                               (1000000007))) *
                         ((((n / (i - 1)) - (n / i + 1) + 1) -
                           ((n / (i - 1)) - (n / i + 1) + 1) / (1000000007) *
                               (1000000007)))) /
                            (1000000007) * (1000000007)) *
                       sb)) /
                         (1000000007) * (1000000007)) *
                        (i - 1)) /
                 (1000000007) * (1000000007));
  }
  return (ans + 1000000007) % 1000000007;
}
int main() {
  long long n, m;
  while (~scanf("%I64d %I64d", &n, &m)) {
    if (n > m)
      printf("%I64d\n", f(n, m));
    else {
      printf("%I64d\n", ((m - n) % 1000000007 * (n % 1000000007) % 1000000007 +
                         f(n, n - 1)) %
                            1000000007);
    }
  }
  return 0;
}
