#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = 2e18;
long long pw(long long a, long long b) {
  if (b == 0) return 1;
  long long x = pw(a, b / 2);
  x = (x * x) % mod;
  if (b & 1) x = (x * a) % mod;
  return x;
}
long long n, q, m;
long long a, b;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long repo = pw(2, mod - 2);
  cin >> a >> b;
  long long ans = 0;
  for (long long k = 1; k < b; k++) {
    long long c = a * k;
    long long r = c / k;
    (ans += ((((a * (a + 1) / 2) % mod) * ((k * b) % mod)) % mod +
             ((a)*k) % mod)) %= mod;
  }
  cout << ans;
}
