#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  long long sum = 0;
  if (b == 1) {
    cout << 0;
    return 0;
  }
  for (int r = 1; r < b; r++) {
    sum = (sum + (((r * b) % 1000000007) * (((a * (a + 1)) / 2) % 1000000007) +
                  r * a) %
                     1000000007) %
          1000000007;
  }
  cout << sum;
  return 0;
}
