#include <bits/stdc++.h>
using namespace std;
int64_t seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline int64_t rnd(int64_t l = 0, int64_t r = INT_MAX) {
  return uniform_int_distribution<int64_t>(l, r)(rng);
}
template <typename T, typename G>
ostream& operator<<(ostream& out, const pair<T, G>& a) {
  return out << "( " << a.first << ", " << a.second << ")";
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
  out << "[ ";
  for (const auto& i : a) out << i << ", ";
  return out << "]" << endl;
}
template <typename T>
ostream& operator<<(ostream& out, const set<T>& a) {
  out << "{ ";
  for (const auto& i : a) out << i << ", ";
  return out << "}" << endl;
}
template <typename T, typename G>
ostream& operator<<(ostream& out, const map<T, G>& a) {
  out << "< ";
  for (const auto& i : a) out << i << ", ";
  return out << ">" << endl;
}
template <typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
                   ostream&>::type
operator<<(ostream& out, T (&a)[N]) {
  out << "[ ";
  for (size_t i = 0; i < N; ++i) out << a[i] << ", ";
  out << "]" << endl;
  return out;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << (H) << " ";
  debug_out(T...);
}
const int64_t mod = 1000000007;
int64_t md(int64_t first, int64_t mdo = mod) {
  assert(first >= 0);
  while (first < 0) first += mdo;
  return first % mdo;
}
int64_t ap(int64_t a, int64_t d, int64_t n) {
  a = md(a);
  n = md(n);
  d = md(d);
  int64_t sm = 0, mi2 = 500000004;
  sm = md(n * mi2);
  sm = md(sm * md(md(2LL * a) + md(d * md(n - 1LL))));
  return sm;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int64_t n, m, i;
  cin >> n >> m;
  int64_t prv = n, ans = 0;
  for (i = 1; i * i <= n && i <= m; i++) {
    int64_t st = (n / (i + 1LL) + 1LL);
    int64_t rem = n % i;
    ans = md(ans + rem);
    if (st <= m && st > i) {
      int64_t nn = min(m, prv) - st + 1LL;
      ans = md(ans + ap(n % min(m, prv), i, nn));
    }
    prv = st - 1;
  }
  if (m > n) {
    ans = md(ans + md(md(m - n) * md(n)));
  }
  cout << ans << "\n";
  return 0;
}
