#include <bits/stdc++.h>
using namespace std;
inline long long mod_mult_inverse(long long a, long long m) {
  long long x = 0, lastx = 1;
  long long y = 1, lasty = 0;
  long long b = m;
  long long aux;
  while (b != 0) {
    long long quotient = a / b;
    long long aux;
    aux = b;
    b = a % b;
    a = aux;
    aux = x;
    x = lastx - quotient * x;
    lastx = aux;
    aux = y;
    y = lasty - quotient * y;
    lasty = aux;
  }
  if (a != 1) return 0;
  x = lastx;
  if (x < 0) return x + m;
  return x;
}
long long a, b;
long long m = 1000000007;
long long mu(long long a, long long b) { return (a * b) % m; }
long long g() {
  long long s = 0, x;
  for (long long x = 1; x < 100000; x++) {
    if (x % b == 0) continue;
    if ((x / b) / (x % b) > a) {
      continue;
    }
    cout << x << endl;
    s = (s + x) % m;
  }
  return s;
}
long long h(long long i) {
  long long x;
  for (long long p = 0; p < 10000; p++) {
    x = p * a + i;
    if ((x / b) / (x % b) > a) {
      continue;
    }
    cout << x << endl;
  }
  return mu(a, i) + i - 1ll;
}
long long pre(long long p) { return mu(mu(p, p + 1), mod_mult_inverse(2, m)); }
int main() {
  long long sum = 0;
  cin >> a >> b;
  long long mu2 = mod_mult_inverse(2, m);
  long long res = mu(b, mu(mu(mu(a, a + 1), mu2), mu(mu(b, b - 1), mu2))) +
                  mu(a, mu(mu(b, b - 1), mu2));
  cout << (res % m) << endl;
  return 0;
}
