#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long mod(long long x) {
  x %= MOD;
  if (x < 0) x += MOD;
  return x;
}
const bool D = 0;
int main() {
  if (D) {
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
  } else {
  }
  int a;
  long long b;
  scanf("%d%I64d", &a, &b);
  long long t = b - 1;
  t = mod(t * (t + 1) / 2);
  long long ans = 0;
  for (int k = 1; k <= a; ++k) {
    ans = mod(ans + mod(t * mod(k * b + 1)));
  }
  printf("%I64d\n", ans);
  return 0;
}
