#include <stdio.h>
unsigned long long p=1000000007;
int main()
{
    unsigned long long a,b,s,A,B,C;
    scanf("%llu%llu",&a,&b);
    A=((a+1)*a/2)%p;
    B=((A*b)+a)%p;
    C=(b*(b-1)/2)%p;
    s=(B*C)%p;
    printf("%llu\n",s);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define int long long int
#define ld long double
#define pb push_back
#define mod 1000000007
signed main(){
	int a,b;
	cin>>a>>b;

	if(b==1){cout<<0<<endl;return 0;}

	int x=(a*(a+1)/2)%mod;
	int y=(b*(b-1)/2)%mod;
	int z=(b*x+a)%mod;
	int ans=(y*z)%mod;
	cout<<ans<<endl;

	return 0;
}

# include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef set<ll> sll;

#define out1(x)cout<<#x<<" is "<<x<<endl
#define out2(x,y)cout<<#x<<" is "<<x<<" "<<#y <<" is "<<y<<endl
#define out3(x,y,z)cout<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<" "<<#z<<" is "<<z<<endl;
#define out4(a,b,c,d)cout<<#a<<" is "<<a<<" "<<#b<<"  is "<<b<<" "<<#c<<" is "<<c<<" "<<#d<<" is "<<d<<endl;
#define show(i,a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define exectime() cout<<"execution time "<<(double)(clock() - tStart)/CLOCKS_PER_SEC<<endl;

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define F first
#define S second
#define PI 3.14159265359
#define FastIn std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define swap(VAR1,VAR2) VAR1=VAR1^VAR2;VAR2=VAR1^VAR2;VAR1=VAR1^VAR2

const ll MAXN    = ll(5e6);
const ll INF     = ll(1e17);
const ld EPS     = ll(1e-9);
const ll MOD     = ll(1e9) + 7;
const ll MILLION = ll(1e6);
const ll BILLION = ll(1e9);
const ll ONE     = ll(1);

int main(){
    FastIn;
    //clock_t tStart = clock();

    ll a,b,A,B,ans;
    cin>>a>>b;

    A = ((a*(a+1))/2)%MOD;
    B = ((b*(b-1))/2)%MOD;

    ans = (A*b + a)%MOD;

    ans = (ans*B)%MOD;

    cout<<ans<<endl;
    //exectime();
    return 0;
}

#include<bits/stdc++.h>
#define INF 2450
using namespace std;

/*
 15 + 2 +
*/
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

const int MxN = 32768;

int dp[15][MxN+5];

class TurntableService{
	int sz;
	int maxSum;

	vector < set <int > > favs;

	int minDis(int i, int j){
		if(i > j) swap(i,j);

		return min( j-i, i-j+sz );
	}
public:

	int solve(int i, int sum, int counter){
		//cout << i<< " " << sum << endl;

		if(sum == maxSum){
			return  0;
		}

		if(dp[i][sum]!=-1)
            return dp[i][sum];

		int new_sum=sum;
		int c=0;
		for(int j=1; j<=maxSum && c<sz; j = (j<<1)){ /// c represents item number
			bool exists = (favs[c].find( (i+c)%sz ) != favs[c].end());
			if(exists)
				new_sum = (new_sum | j);
			c++;
		}
		if(sum == new_sum)
            return INF;
	//	cout << new_sum << endl;
		if(new_sum == maxSum){
			return 15;
		}
		int ans =INT_MAX,op1=INF,op2 = INF;
		for(int j=0; j<sz; j++){
			int stepsCost = minDis(j,i)+1;
			if(i == j) continue;
			op2 = solve(j,new_sum,0) + stepsCost + 15;
			ans = min(ans, min(op1,op2));
		}

		return dp[i][sum]=ans;
	}

	int calculateTime(vector <string> fav){
		sz = fav.size();
		maxSum = binpow(2,sz)-1;
		memset(dp,-1,sizeof(dp));

		favs.assign(sz+1,set<int>());
		for(int i=0; i<fav.size(); i++){
			int k=0;
			for(int j=0; j<fav[i].size(); j++){
				if(fav[i][j] == ' '){
					favs[i].insert(k);
					k=0;
				}
				else {
					 k = k * 10;
					 k += fav[i][j]-'0';
				}
			}
			favs[i].insert(k);
		}

		//cout << *favs[0].begin() << endl;
		int new_sum=0;
		int c=0;
		for(int j=1; j<=maxSum && c<sz; j = (j<<1)){ /// c represents item number
			bool exists = (favs[c].find( (0+c)%sz ) != favs[c].end());
			if(exists)
				new_sum = (new_sum | j);
			c++;
		}
		int ans = INF;
		ans = min(solve(0,0,0),ans);
		for(int i=1; i<sz; i++)
         ans = min(ans,solve(i,0,0)+i+1);

         return ans;

	}
};
/*
void test(){
    TurntableService t;
    int sz;
    string arr2[] = {"0 2", "1", "0 1"};
     sz = 3;
    cout << t.calculateTime( vector<string>(arr2,arr2+sz) ) << endl;;
    string arr1[] = {"0","0","0"};
    sz = 3;
    cout << t.calculateTime( vector<string>(arr1,arr1+sz) ) << endl;;
    string arr0[] = {"4","1","2","3","0"};
    sz =5;
    cout << t.calculateTime( vector<string>(arr0,arr0+sz) ) << endl;
    string arr3[] = {"0 004", "2 3", "0 01", "1 2 3 4", "1 1"};
    sz = 5;
    cout << t.calculateTime( vector<string>(arr3,arr3+sz) ) << endl;;
}*/

int main(){

    int t;
    //cout << (0 | 5) << endl;
    //test();
    long long a,b;
    cin >> a >> b ;
    const long long MOD = 1e9 + 7;
    long long ans=0;
    for(int z=1; z<=b-1; z++){
        ans+= a*z%MOD + b*z%MOD * ( a*(a+1)/2%MOD );
        ans = ans %MOD;
    }
    cout << ans << endl;
}

#include <cstdio>

long long mod = 1000000007 ;

int main(void)
{
    long long a, b ;

    scanf("%I64d%I64d", &a, &b) ;

    long long B = (b*(b-1)/2) % mod ;
    long long A1 = (a*(a+1)/2) % mod ;
    long long A = (A1*b+a) % mod ;
    long long answer = (A*B) % mod ;

    printf("%I64d\n", answer) ;

    return 0 ;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<ctime>
#include<limits>
#include<iomanip>
#include<cstdlib>
#include<list>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>

using namespace std;

const int mod = 1e9+7;

long long Pow(long long b, long long p = mod-2)
{
    if(p==0) return 1;

    long long z = Pow(b,p/2);
    z = (z*z)%mod;

    if(p%2 == 1) z = (z*b)%mod;

    return z;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long a, b;
    cin >> a >> b;

    long long r, q, x1, x2;

    x1 = (b*(b-1))%mod;
    x1 *= Pow(2);
    x1 %= mod;

    x2 = (x1*(2*b-1))%mod;
    x2 *= Pow(3);
    x2 %= mod;

    r = (x1*a)%mod;

    q = (a*(a+1))%mod;
    q = (q*x1)%mod;
    q *= Pow(2);
    q %= mod;

    long long ans;
    ans = (q*b)%mod;
    ans = (ans+r)%mod;

    cout << ans << "\n";
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD = (ll)1e9 + 7;

int main() {
    ll a, b;
    cin >> a >> b;
    cout << (((((a * (a + 1) / 2) % MOD) * b + a) % MOD) * ((b * (b - 1) / 2) % MOD)) % MOD << endl;
    return 0;
}

#include<iostream>
using namespace std;
int main(){
long long int a,b,u=1000000007;
cin>>a>>b;
long long int h=b*1LL*(b-1);
h=h/2;
h=h%u;
long long int p=a*1LL*(a+1);p=p/2;
p=p%u;p=p*b;p=p+a;p=p%u;
h=h*1LL*p;h=h%u;//h=h*1LL*(a+2);
h=h%u;
//while(h<0)h=h+u;
cout<<h<<endl;
}

#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF){
        long long ans=0;
        for(long long  i=1;i<m;i++)
            {
                long long  k = n ;
                long long temp=m;
                ans+=k*(1+k)/2% 1000000007*i% 1000000007*temp% 1000000007+k*i% 1000000007;
                ans=ans% 1000000007;
            }
        cout << ans << endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define LD long double
#define gc getchar_unlocked
#define pc putchar_unlocked
#define MOD 1000000007
#define MAXN 1000005
#define bitcount _builtin_popcount

template<typename T>T absll(T X)
{
    if(X<0)
        return -1*X;
    else
        return X;
}

LL gcd(LL A,LL B)
{
    if(B==0)
        return A;
    else
        return gcd(B,A%B);
}

int main()
{
    LL A,B;
    cin>>A>>B;
    LL sum=B;
    sum*=(B-1);
    sum/=2;
    sum%=MOD;
    LL ans=0LL;
    for(LL i=1;i<=A;i++)
    {
        LL tmp=i*B;
        tmp%=MOD;
        tmp+=1LL;
        tmp%=MOD;
        tmp*=sum;
        tmp%=MOD;
        ans+=tmp;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define SZ(x) ((int)((x).size()))
#define PB(x) push_back(x)
#define INF (0x3f3f3f3f)
#define MEMSET(x,v) memset(x,v,sizeof(x))

typedef long long LL;
typedef pair<int, int> PII; typedef pair<PII, int> PII2;

#define MOD (1000000007)

int main() {
    LL a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << "0" << endl;
        return 0;
    }
    LL temp = (b * (b - 1) / 2) % MOD;
    LL temp2 = (a * (a + 1) / 2) % MOD;
    cout << (temp * (a + (b * temp2 % MOD)) % MOD) % MOD << endl;

    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
using namespace std;
const int mod = 1e9+7;
const int N = 1e5+7;

int main()
{
    ios::sync_with_stdio(0);

    ll a,b;
    cin >> a >> b;
    //a = 1e7;
    //b = 1e7;
    //scanf("%d %d",&a,&b);
    ll ans = 0;
    //b--;
    ll d = b-1;
    if (b == 1) {cout << 0 << endl;return 0;}
    for (ll i = 1 ; i <= a ; i++)
    {
        ll x = d;
        if (d%2 == 0) {x/=2;x%=mod;x = (((x*(d+1))%mod)*i)%mod;}
        else x = ((((((d+1)/2)%mod)*x)%mod)*i)%mod;
        ans += ((x)*b)%mod;
        //cout << ans << endl;
        if (ans < 0) assert(0);
        ans%=mod;
        ans += ((d)*(d+1)/2);
        //cout << ans << endl;
        if (ans < 0) assert(0);
        ans%=mod;
        //cout << ans << endl;
    }
    //printf("%I64d\n",ans);
    cout << ans << endl;
    return 0;
}

#include <iostream>

using namespace std;

typedef long long ll;

const ll M = ll(1.0e9) + 7;

int main() {
    ll A, B;
    cin >> A >> B;
    //cout << (((B * (B - 1) / 2) % M) * (((A * (A + 1) / 2) % M) * B + A) % M) % M;
    cout << ((A+1)*A/2%M*B+A)%M*(B*(B-1)/2%M)%M;
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define N 100005
#define mod 1000000007

int main()
{
    ll a,b,i,n,ans=0,first,last,t;

    cin>>a>>b;
    ll one=1;

    for(i=1;i<b;i++)
    {
        first=b*i+i;
        last=(first+(((b*i)%mod)*(a-1))%mod)%mod;
        t=(first+last)%mod;
        n=a;
        ans+=((n*t)%mod*500000004)%mod;
        ans%=mod;
    }

    cout<<ans<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<double,double> dd;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<ii> > vvip;
typedef vector<ii> vii;
#define pb push_back
#define F first
#define S second
#define MOD 1000000007
#define NA -1
#define ALL(v) v.begin(),v.end()
#define mp make_pair
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define db(x) {cout << #x << " = " << (x) << endl;}
#define dba(a, x, y) {cout<<#a<<" :";FOR(i123,x,y)cout<<setw(4)<<(a)[i123];cout<<endl;}
#define foreach(e, x) for (__typeof(x.begin()) e = x.begin(); e != x.end(); e++)
#define clr(x) memset(x,0,sizeof(x));
#define sz(x) int((x).size())
#define endl '\n'
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;

//const ld PI = acos(-1);
#define PI acos(-1)
#define re return
typedef pair<pll,ll> ppll;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int main ()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	ios_base::sync_with_stdio(0); cout.precision(15); cout << fixed; cout.tie(0); cin.tie(0);
	ll a,b;
	cin>>a>>b;
	ll x = b*(b-1);x/=2;x%=MOD;
	ll y = a*(a+1);
	y/=2;y%=MOD;
	y*=b;
	y+=a;
	y%=MOD;
	ll r = x*y;
	r%=MOD;
	cout<<r<<endl;
	re 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e17;
const int N=1e5+5;
int mult(int a,int b){
	a%=mod;
	b%=mod;
	int res=a;
	res*=b;
	if(res>=mod){
		res%=mod;
	}
	return res;
}
int expo(int base,int exponent){
    int ans=1;
    base%=mod;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
int inv_mod(int k){
	return expo(k,mod-2);
}
int calc(int x){
	x%=mod;
	return (mult(x,mult(x+1,inv_mod(2LL))));
}
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<mult(calc(b-1),a+mult(b,calc(a)));
}

#include <bits/stdc++.h>
using namespace std;
//printf("%.7f\n", double value);

typedef long long ll;
ll a,b;
const ll mod = 1000000007;

int main () {
  cin >> a >> b;
  ll ret = 0;
  for(ll d=1; d<b; d++) {
    ll asum = a * (a+1) /2 % mod;
    ll part1 = b*d % mod;

    ret += part1 * asum + d* a;
    ret = ret % mod;

  }
  cout << (ret + mod) % mod << endl;
  return 0;
}

#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0, _ = n; i < n; i++)
#define rep1(i, n) for (int i = 1, _ = n; i <= n; i++)
#define lop(i, s, e) for (int i = s, _ = e; i < _; i++)
inline int read() { int ret; scanf("%d", &ret); return ret; }
const int mod = 1000000007;
int main()
{
	long long a = read(), b = read();
	long long sum = 0;
	for (int i = 1; i < b; i++)
	{
		sum += a * i % mod;
		long long temp = a * (a + 1) / 2 % mod;
		sum += i * b % mod * temp % mod;
		sum %= mod;
	}
	printf("%I64d\n", sum);
	return 0;
}

#include<stdio.h>
#include<algorithm>
using namespace std;
long long a,b,mod=1e9+7;
int main(){
	scanf("%lld%lld",&a,&b);
	printf("%lld\n",((a*(a+1)/2%mod*b%mod+a)%mod*((b*(b-1)/2)%mod))%mod);
}

/** I can do this all day **/

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"

const int N = 1e6 + 10;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ll inf = 8e18;
const int LOG = 22;

ll pw(ll a , ll b, ll M)  { return (!b ? 1 : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M : pw(a * a % M, b / 2, M))); }

int main()
{
        fast_io;
	ll ans = 0, inv2 = pw(2, mod - 2, mod);
	ll a, b;
	cin >> a >> b;
	for(ll r = 1; r < b; r ++)
	{
		ans = (ans + a * r) % mod;
		ll cu = b;
		cu = (cu * a) % mod;
		cu = (cu * (a + 1)) % mod;
		cu = (cu * inv2) % mod;
		cu = (cu * r) % mod;
		ans = (ans + cu) % mod;
	}
	cout << ans << endl;
        return 0;
}
/*!
        stay away from negative people they have a problem for every solution !
*/

#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <iomanip>
#include <deque>

using namespace std;

#define fr first
#define sd second
#define pb push_back
#define mp make_pair

#define endl '\n'

#define forr(i, n) for(ll (i) = 0LL; (i) < (n); (i)++)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef vector < vector < double > > vvd;
typedef vector < double > vd;
typedef vector < pair < double, double> > vdd;
typedef vector < vector < long long > > vvl;
typedef vector < long long > vl;
typedef vector < pll > vll;

int INT_MAX_VAL = (int)  0x3F3F3F3F;
int INT_MIN_VAL = (int) -0x3F3F3F3F;
ll LONG_MAX_VAL = (ll)   0x3F3F3F3F3F3F3F3F;
ll LONG_MIN_VAL = (ll)  -0x3F3F3F3F3F3F3F3F;

#define MAXN 500006
#define MOD 1000000007

void brute(ll a, ll b)
{
	ll res = 0;
	for(ll x = 1; x < 1e7; ++x) {
		if(x % b == 0) continue;
		ll d = x / b;
		ll m = x % b;
		if(d % m != 0) continue;
		ll k = d / m;
		if(k > a) continue;
		if(k <= 0) continue;
		res += x;
		res %= MOD;
	}
	cerr << res << endl;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll a, b; cin >> a >> b;
	ll res = 0;
	for(ll k = 1; k <= a; ++k) {
		ll t = ((b) * (b - 1) / 2) % MOD;
		ll s = (k * b + 1) % MOD;
		res += t * s;
		res %= MOD;
	}

	//brute(a, b);
	cout << res << endl;

	return 0;
}

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

typedef unsigned long long LL;
LL const Mod = 1000000007;

LL sq_sum(LL n) {
	LL ret = n;
	ret = (n * (n+1));
	ret /= 2;
	if (ret % 3 == 0) {
		return ((ret/3) % Mod * (2*n+1)) % Mod;
	} else {
		return 	((ret % Mod) * ((2*n+1)/3)) % Mod;
	}
}

LL check(LL a, LL b) {
	LL ret = 0;
	for (LL x = b; x < 100000; ++x) {
		if (x % b != 0) {
			LL t1 = x/b;
			LL t2 = x % b;
			if (t1 % t2 == 0 && t1/t2 <= a) ret += x;
		}
	}
	return ret;
}

int main() {
	LL a, b;
	while (cin >> a >> b) {
		cout << (((a*(a+1)/2)%Mod * b + a)%Mod *((b*(b-1)/2)%Mod))%Mod << endl;
		//cout << check(a, b) << endl;
	}
}

#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#include<cmath>
#include<cstring>
#include<utility>
#define pb push_back
#define CLR(x) memset(x,0,sizeof(x))
#define __CLR(x) memset(x,-1,sizeof(x))
#define REP(i,n) for(int i=0;i<n;i++)
#define Debug(x) cout<<#x<<"="<<x<<" "<<endl;
#define For(i,l,r) for(int i=l;i<=r;i++)
#define ll long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<11
using namespace std;

const int maxn=1000100;
const int mod=1000000000+7;
const int INF=(1<<30);
const double eps=1e-8;
const double pi=3.1415926535898;
const double e=2.718281828459;

inline int getint()
{
   int c;
   while(c=getchar(),(c<'0'||c>'9')&&(c!='-')&&(c!=EOF));
   if(c==EOF)
   {
      return -1;
   }
   bool flag=(c=='-');
   if(flag)
   {
      c=getchar();
   }
   int x=0;
   while(c>='0'&&c<='9')
   {
      x = (x<<3)+x+x+c-'0';
      c=getchar();
   }
   return flag?-x:x;
}
inline ll getll()
{
   ll c;
   while(c=getchar(),(c<'0'||c>'9')&&(c!='-')&&(c!=EOF));
   if(c==EOF)
   {
      return -1;
   }
   bool flag=(c=='-');
   if(flag)
   {
      c=getchar();
   }
   ll x=0;
   while(c>='0'&&c<='9')
   {
      x = (x<<3)+x+x+c-'0';
      c=getchar();
   }
   return flag?-x:x;
}
inline void output(int x)
{
   if(x<0)
   {
      putchar('-');
      x=-x;
   }
   int len=0,buf[20];
   while(x)
   {
      buf[len++]=x%10;
      x/=10;
   }
   if(!len)
   {
      buf[len++]=0;
   }
   while(len--)
   {
      putchar(buf[len]+'0');
   }
   putchar('\n');
}

inline void output(ll x)
{
   if(x<0)
   {
      putchar('-');
      x=-x;
   }
   ll len=0,buf[20];
   while(x)
   {
      buf[len++]=x%10;
      x/=10;
   }
   if(!len)
   {
      buf[len++]=0;
   }
   while(len--)
   {
      putchar(buf[len]+'0');
   }
   putchar('\n');
}

int main()
{
   long long a,b,ans;
   ios::sync_with_stdio(false);
   while(cin>>a>>b)
   {
       ans=(((a*(a+1)/2)%mod*b)%mod+a)%mod*((b*(b-1)/2)%mod);
       cout<<ans%mod<<endl;
   }
}

#include <bits/stdc++.h>
using namespace std;
#define inc(i)          (i = -~i)
#define ll long long
#define mod  1000000007
#define modinv2 500000004

ll summation(ll i){
    ll ret = (i*(i+1))/2 ;
    ret = ret %mod ;
    return ret ;
}

int main(){
    ll a , b , i , q , r ;
    cin >> a >> b ;
    ll ret = 0 ;
    ll u = summation(a) ;
    for( i = 1 ; i < b ; inc(i)){
        q = (i*a)%mod + ((b*i)%mod * u )%mod ;
        ret += q ;
        ret = ret%mod ;
    }
    cout<<ret<<endl;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1000000007;

ll a,b;
ll ans;
ll k;

int main()
{
    ans = 0;
    cin >> a >> b;
//    if(b == 1){
//        cout << 0 << '\n';
//        return 0;
//    }
    ll t=0;
    t = b*(b-1)/2;
    t%=mod;
    ans = t*a%mod;
    for(k = 1;k <= a;k++){
        ans = (ans+t*b%mod*k%mod)%mod;
    }
    cout << ans << '\n';
    return 0;
}

// In the Name of Allah
// Ya Ali!
#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;

#define F fisrt
#define S second
#define mp make_pair
#define pb push_back
#define all(x) x.begin() , x.end()

const ll maxn = 2e5 + 10;
const ll INF = 1e18 ;

ll n , a , b , mod = 1e9 + 7 ;

int main()
{
 std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

 cin >> a >> b ;
 if(b == 0)return cout << 0 , 0 ;

 ll ans = 0 ;
 for(int i = 1 ; i <= a ; i ++){
   ll x = (i*b)+1 ;
   ll x2 = (b*(b-1))/2 ;
   ans += ((x%mod)*(x2%mod))%mod ;
 }
 cout << ans%mod ;

    return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int P=1e9+7;
ll a,b,ans,x,y;
int main(){
	scanf("%lld%lld",&a,&b);
	ans=0;
	for (int i=1; i<=a; i++){
		x=(i*b+1)%P;
		y=(b*(b-1)/2)%P;
		ans+=x*y%P;
	}
	printf("%I64d\n",ans%P);
}

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int MOD = 1e9 + 7;

typedef long long Long;
typedef double Double;
typedef int Int;

#define scanf		SF
#define mem(a,b)	memset(a,b,sizeof(a))
#define PI		3.141592653589793
#define BE(a)		a.begin(),a.end()
#define sortc(a)	sort(BE(a),comp)

int main()
{
	ios::sync_with_stdio(false);

	Long a, b, aa, bb, r;

	while(cin >> a >> b)
	{
		aa = (((1 + a) * a >> 1) % MOD * b + a) % MOD;
		//aa = ((1 + a) * a >> 1) % MOD;
		//aa = (aa * b + a) % MOD;
		bb = (b * (b - 1) >> 1) % MOD;
		r = (aa * bb) % MOD;
		cout << r << endl;
	}
	return 0;
}

#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std;
using namespace __gnu_cxx;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REV(i,b,a) for(ll i=(a);i>=(b);--i)
#define pb push_back
#define re             return
#define oo (1<<30)
#define OO (1ll<<50)
#define INF 1000000000000
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define sc(x)   scanf("%d",&x);5.
#define sc2(x,y)   scanf("%d %d",&x,&y);
#define scl(x)   scanf("%lld",&x);
#define scl2(x,y) scanf("%lld %lld",&x,&y);
#define PI                 3.141592653589793
#define ECONST                      2.71828
#define iter(it,s) for(__typeof(s.begin())it = s.begin();it!=s.end();it++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ii> vii;
typedef pair<ll, int> pli;
typedef vector<vii> vvii;
typedef pair<string, int> si;
typedef vector<si> vsi;
typedef map<string, int> msi;
typedef set<int> sti;

ll dx[] = { 0, 0, 1, -1 };
ll dy[] = { 1, -1, 0, 0 };

const int MOD = 1e9 + 7;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
//freopen("output.txt", "wt", stdout);
#endif
    ll a, b, mul;
    ll ans = 0;
    scl2(a, b);
    mul = (b * (b - 1) / 2) % MOD;
    for (int k = 1; k <= a; ++k)
        ans += (mul * ((k * b + 1) % MOD)), ans %= MOD;
    printf("%d", int(ans));
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 */

#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define MOD 1000000007
LL a,b;
int main()
{
	scanf("%I64d%I64d",&a,&b);
	printf("%I64d\n",(a*(a+1)/((LL)2)%MOD*b%MOD+a)%MOD*(b*(b-1)/((LL)2)%MOD)%MOD);return 0;
}

#include<stdio.h>
#include<string.h>
#define ll long long
#define mod 1000000007
int main()
{
    ll a,b;
    while(scanf("%I64d%I64d",&a,&b)!=EOF)
    {
        ll ans=0;
        for(ll i=1;i<=a;i++)
        {
            ll c=(i*b+1)%mod;
            ll d=((b-1)*b/2)%mod;
            ans=(ans+c*d)%mod;
        }
        printf("%I64d\n",ans);
    }
    return 0;
}

#include <bits/stdc++.h>

#define INF 0x3f3f3f3f
#define NINF -0x3f3f3f3f
#define MOD 1000000007LL

using namespace std;

typedef pair<int,int> pii;

int main (int argc, char const* argv[])
{
	int a,b;
	scanf("%d %d",&a,&b);

	long long sr = (1LL*b*(1LL*b-1LL))/2LL;
	sr %= MOD;

	long long sa = (1LL*a*(1LL*a+1LL))/2LL;
	sa %= MOD;

	sa = (1LL*b*sa)%MOD;

	long long ans = 0;
	for (long long i = 1; i < b; i += 1)
	{
		long long s = (i*sa)%MOD;
		long long ss = (i*a)%MOD;

		ans = (ans+s)%MOD;
		ans = (ans+ss)%MOD;
	}

	printf("%lld\n",ans);

	return 0;
}

#include <cstdio>
#include <algorithm>

using namespace std;

const long long MOD = 1000000007;

long long a, b;

int main() {

    scanf("%lld %lld", &a, &b);

    long long p = b * (b - 1) / 2 % MOD;
    long long q = (a * (a + 1) / 2 % MOD * b + a) % MOD;

    printf("%lld\n", p * q % MOD);

    return 0;

}

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define ll long long
using namespace std;
const int  mod = 1000000007;
    ll a, b,ans;
int main()
{
    cin >> a >> b;
    ans = b*(b-1)%mod*a%mod*250000002%mod*((a+1)*b%mod+2)%mod;
    cout << ans<<endl;
}

#include<bits/stdc++.h>
using namespace std;

const int delta = 1e9 + 7;
long long a, b;

int main()
{
	cin >> a >> b;
	long long ans = ((a * (a + 1) / 2) % delta) * (b % delta) + (a % delta);
	ans %= delta;
	ans = ans * ((b * (b - 1) / 2) % delta);
	ans %= delta;
	cout << ans << endl;
	return 0;
}

#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/ACM/output.txt", "w", stdout);
  //freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
    //cout << "Case #" << testNum++ << ": ";
    //cerr << testNum << endl;
    solve(true);
    //cerr << testNum - 1 << endl;
  }
  cout.flush();
#ifdef AIM1
  while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

void precalc() {

}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

#define int li
const int mod = 1000000007;

void solve(bool read) {
  int a, b;
  cin >> a >> b;
  int res = 0;
  for (int x = 1; x < b; ++x) {
    res += a * x;
    res += b * x % mod * (a * (a + 1) / 2 % mod);
    res %= mod;
  }

  cout << res << endl;

}

#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <queue>
#include <deque>
#include <stack>
#include <memory.h>
#include <complex>
#include <algorithm>
using namespace std;
double PI = 3.1415926535897932384626433832795;
typedef complex<double> base;
typedef vector<int> vint;
typedef long long LL;
LL mod = 1000 * 1000 * 1000 + 7;
LL pow(LL a, LL n)
{
	if ( n == 1)
		return a;
	if ( n % 2 == 0)
		{
			LL b = pow (a, n / 2);
			return b * b % mod;
	}
	else
		return a * pow(a, n - 1) % mod;
}
int main()
{
	LL a , b;
	cin >> a >> b;
	int t = 2 * b - (b + 1);
	LL sum = 0;
	for ( LL i = 1; i < b; i ++)
	{
		LL a1 = (i + b* i) % mod;
		LL an = (1LL * (i + (1LL * i * a) % mod * b % mod) % mod) % mod;
		//sum = (sum + (((a1 + an) * a) % mod) / 2) % mod;
		sum = (sum + (((a1 + an) * a) % mod) * pow(2, mod - 2)) % mod;
		int ost = i % b;
		int v = b * i / b;
	//	cout << v << ' '  << ost << endl;
	}
	cout << sum << endl;
	return 0;
}

#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 30
#define T printf("***\n");
#define arr0 memset(arr,0,sizeof(arr));
#define arr1 memset(arr,-1,sizeof(arr));
#define for_i for(i=1;i<=n;i++)
#define for_j for(j=0;j<n;j++)
#define pf printf
#define cf scanf
int main()
{
	__int64 a,b,k,n,mod=1000000007;
	scanf("%I64d%I64d",&a,&b);
	__int64 t=(b*(b-1)/2)%mod;
	__int64 t1=(a*(a+1)/2)%mod;
	__int64 t2=(t1*b+a)%mod;
	k=(t*t2)%mod;
	printf("%I64d",k);
}

#include<bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Sort(x) sort(all(x))
#define RSort(x) rsort(all(x))
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define SUM(x) accumulate(all(x),0)
#define pb push_back
#define MP make_pair
#define FO(i,n) for(int i = 0;i<n;i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool> > vb;

#define READ(s) freopen(s, "r", stdin)
#define WRITE(s) freopen(s, "w", stdout)
const int mod = 1000000007;
int main() {
	ios::sync_with_stdio(false);
	//READ("17.in");
	//WRITE("17.out");

	ll sm = 0, a, b;
	cin >> a >> b;

		sm += ((b*( ((a)*(a+1))/2%mod ))%mod+a)%mod * (((b * (b - 1)) / 2)%mod);
		sm %= mod;

	cout << sm % mod;
	return 0;
}

#include <stdio.h>
#define mod 1000000007
int a,b,A;
main() {
	scanf("%d%d",&a,&b);
	A=1ll*(b-1)*b/2%mod*(1ll*a*(a+1)/2%mod*b%mod+a)%mod;
	printf("%d\n",A);
}

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

const int N=1e5+10;
const int mod=1000000007;

int main(){
    //freopen("a.txt", "r", stdin);
    //freopen("answers.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    ll res=1LL*b*(b-1)/2;
    res%=mod;
    ll res1=1LL*a*(a+1)/2;
    res1%=mod;
    res1=(res1*b)%mod;
    res1=(res1*res)%mod;
    res=(res*a)%mod;
    res1=(res1+res)%mod;
    cout<<res1<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double
#define db double
#define str string
#define int long long

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>

#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18;
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

int32_t main()
{
    fast;
   int a,b;
   cin>>a>>b;
   int res=0;
   int p=(b%md*(b-1)%md)%md;
   p=(p%md*power_md((int)2,md-2)%md)%md;
   res=(a%md*p%md)%md;
   int q=(a%md*(a+1)%md)%md;
   q=(q%md*power_md((int)2,md-2))%md;
   p=(p%md*b%md)%md;
   p=(p%md*q%md)%md;
   res=(res%md+p%md)%md;
   cout<<res<<"\n";
   return 0;
}

#include<iostream>
using namespace std;
int main()
{
	long long int a,b;
	while(cin>>a>>b)
	{
		long long x=(b*(b-1)/2)%1000000007;
		long long y=(b*((a*(a+1)/2)%1000000007)+a)%1000000007;
		cout<<(x*y)%(1000000007)<<endl;
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

#define MOD 1000000007LL

ll fun(ll a, ll b) {
    ll tres = 0;
    for(int i = b; i <= a*b*1000; i++) {
        if(i%b) {
            ll q = i/b, mod = i%b;
            if(q%mod == 0 && q/mod <= a && q/mod >= 1)
                cout << i << '\t' << i/b << '\t' << i%b << ' ' << endl,
                tres = (tres+i)%MOD;
        }
    }
    return tres;
}

int main() {
//  freopen("test.in", "r", stdin);

    ll a,b;
    cin >> a >> b;
//  for(ll a = 1; a < 50; a++)
//      for(ll b = 1; b < 120; b++) {
//          ll res = 0, rsum = (a*(a+1)/2)%MOD;
//
//          for(ll i = 1; i < b; i++) {
//              ll resA = (a*i)%MOD;
//              ll resB = b*(rsum*i)%MOD;
//      //      cout << i << ' ' << resA << ' ' << resB << endl;
//              res = (res + resA + resB)%MOD;
//          }
//
//          if(fun(a, b) != res) {
//              cout << a << ' ' << b << endl;
//              cout << fun(a, b) << ' ' << res << endl;
//              a = b = 1000;
//          }
//      }
//  return 0;
//  cout << fun(a, b) << endl;

    ll res = 0, rsum = (a*(a+1)/2LL)%MOD;
    for(ll i = 1; i < b; i++) {
        ll resA = (a*i)%MOD;
        ll resB = (b*((rsum*i)%MOD))%MOD;
//      cout << i << ' ' << resA << ' ' << resB << endl;
        res = (res + resA + resB)%MOD;
    }
    cout << res << endl;

    return 0;

    for(ll i = 1; i <= a; i++) {
        ll num = min(i, b-1);

        ll subresA = (((b*i)%MOD)*num)%MOD;
        ll subresB = ((num*(num+1))/2LL)%MOD;
//      cout << i << ' ' << subresA << ' ' << subresB << endl;

        res = (res + subresA)%MOD;
        res = (res + subresB)%MOD;
    }

    cout << res << endl;
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <sstream>
#include <stack>
#include <string.h>
#include <list>
#include <time.h>

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define PI 3.14159265358979
#define forn(i, n) for(int i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
#define L(s) (int)((s).size())
#define sz(s) (int)((s).size())
#define ms(x) memset(x,0,sizeof(x))
#define ms1(x) memset(x,-1,sizeof(x))
#define del(y,x) erase(y.begin()+x)

typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;
const int ST = 100010;
const int ST1 = 1000010;
const ll MOD = 1000000007;

ll ABS(ll a) {
    if(a<0)
        return a*(-1);
    else
        return a;
}

ll stress(ll a,ll b){
	ll ans = 0;
	for(int i = 1;i < 20000;i++){
		ll k = i/b;
		ll t = i%b;
		if(k!=0 && t!=0 && k%t==0 && k/t<=a)
			ans+=i;
	}
	return ans;
}
int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	ll a,b;
	cin >> a >> b;
	ll ans = 0;
	for(ll i = 1;i < b;i++){

		ll f = i+b*i;
		f%=MOD;
		ll el1 = (a-1)*a/2;
		ll el2 = f*a;
		el1%=MOD;
		el2%=MOD;
		ll sum = (el2+(b*i)%MOD*el1)%MOD;
		ans+=sum;
		ans%=MOD;
	}
	cout << ans << " ";
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

long long lmt=1000000007 ;

long long ab(long long a){
    long long x=a+1 ;
    if(a%2==0)
        a/=2 ;
    else
        x/=2 ;
    a%=lmt ;
    x%=lmt ;
    return (a*x)%lmt ;
}

int main()
{
    long long a,b ;
    long long sum=0 ;
    cin>>a>>b ;
    sum= (((b*ab(a))%lmt)+a)%lmt;
    sum= (sum*ab(b-1))%lmt ;
    cout<<sum ;
    return 0;
}

#include <stdio.h>
#include <algorithm>
using namespace std;

typedef __int64 ll;
ll A,B;
#define MOD 1000000007

void process()
{
    ll x = (((B - 1) * B) / 2) % MOD;
    ll y = ((A * (A + 1)) / 2) % MOD;
    y = (y * B) % MOD;
    y = (y + A) % MOD;
    ll ans = ( x * y ) % MOD;
    printf("%I64d\n",ans);
}

int main()
{
    scanf("%I64d %I64d",&A,&B);
    process();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define PI 3.14159265358979323846
#define forn(i,s,n) for(int i=s ; i<n ; ++i)
#define fornr(i,s,n) for(int i=n ; i>s ; i--)
#define mp make_pair
#define pb push_back
const int SIZE= 100009;
const int OO = (int)1e9;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int , int > ii;
string s;

int main(){

    ll a , b;
    scanf("%lld %lld" , &a , &b);
    ll m = (b * (b-1) /2)%MOD;
   // cout << m ;

    ll ans=0;
    //cout << k << endl;
    forn(i , 1 , a+1){
    ll qq = i * b ;
    qq %= MOD;
    ll bb = m * (qq+1);
    bb%=MOD;
     (ans+=bb)%=MOD;

    }
    printf("%lld\n" , ans );
}

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<queue>
#include<map>
using namespace std;

int main()
{
    int a,b;
    long long sum=0;
    int MOD=1e9+7;
    cin>>a>>b;
    long long tmp=1LL*b*(b-1)/2%MOD;
    for (int i=1;i<=a;i++)
        sum=(sum+tmp*(1LL*i*b%MOD+1))%MOD;
    cout<<sum<<endl;
    return 0;
}

#include<stdio.h>
#define MAX 1000000007

int main()
{

	_int64 a,b;

	scanf("%I64d %I64d",&a,&b);
	{

	_int64 sum1,sum2;long sum;

	sum1=(b*(b-1)/2)%MAX;
	sum2=(b*(a*(a+1)/2 % MAX)+a)%MAX;

	sum=sum1*sum2 % MAX;

	printf("%ld\n",sum);

	}

	return 0;
}

// In the name of God
// Code by: mrMaster

#include <bits/stdc++.h>

using namespace std;

inline int in() {int x; scanf("%d",&x); return x;}
#define debug(x) cerr << #x << '=' << (x) << endl
#define FOR(i,j,k) for(int i=j;i<k;++i)
#define bpc __builtin_popcount
#define blz __builtin_clz
#define btz __builtin_ctz
#define Size(x) ((int)(x).size())
#define endl '\n'
#define boost ios_base :: sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define pb push_back
#define X first
#define Y second

typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;

const ld EPS = 1e-12;
const int INF = 1e9 + 10;
const ll LINF = 1000ll*1000*1000*1000*1000*1000 + 100;
const int MOD = 1e9 + 7;

ll C(ll t)
{
	return t*(t-1)/2%MOD;
}

int main()
{
	boost;
	ll p,q;
	cin >> p >> q;
	ll v1 = C(p+1) ,v2 = C(q);
	ll ans = (v1*q%MOD*v2%MOD) + (v2*p%MOD);
	ans %= MOD;
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);
const int mod = (int)1e9 + 7;

int a, b;

void read()
{
	cin >> a >> b;
}

void solve()
{
	int ans = 0;
	int sum1 = 0, sum2 = 0;
	for(int i = 1; i <= a; i++) sum1 = (sum1 + i) % mod;
	for(int i = 1; i < b; i++) sum2 = (sum2 + i) % mod;

	ans = (sum1 * 1ll * sum2) % mod;
	ans = (ans * 1ll * b) % mod;

	for(int o = 1; o < b; o++)
		ans = (ans + (o * 1ll * a) % mod) % mod;

	cout << ans << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int MOD = (int) 1e9+7;

int main()
{
    long long a, b, ans = 0, V, K;
    cin >> a >> b;
    if (b == 1) {
        cout << 0 << '\n';
        return 0;
    }
    K = 1;
    V = (b*(b-1)/2) % MOD;
    for (int i = 1; i <= a; ++i) {
        K = (K + b) % MOD;
        ans = (ans + (K * V) % MOD) % MOD;
    }
    cout << ans << '\n';
    return 0;
}

#pragma comment(linker,"/STACK:102400000,102400000")
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <cctype>
#include <list>
#include <stack>
#include <sstream>
#include <set>
#include <map>
#include <complex>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cassert>
#include <bitset>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define mset(a) memset(a,0,sizeof(a))
#define mmset(a) memset(a,-1,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
const int inf=1e9+7;
const long long linf=1e18;
const double pi=acos(-1.0);
typedef long double lf;
typedef vector <int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
template <class T> T sqr(T x){return x*x;}
const double eps=1e-6;
ll fastpow(int m,int n){
	int temp=n;ll ans=1;ll t=m;
	while (temp>0)
	{
		if (temp&1) ans=(ans*t)%inf;
		t=(t*t)%inf;
		temp=temp>>1;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	ll a,b;cin>>a>>b;
	ll ni=fastpow(2,inf-2);
	ll ans=b*(b-1)%inf*ni%inf;
	ll ans1=a*(a+1)%inf*ni%inf*b%inf;
	ans1=(ans1+a)%inf;
	ans=(ans*ans1)%inf;
	cout<<ans<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
const int mod=1e9+7;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
inline ll divi(ll a, ll b) { return (500000004*(a%mod))%mod; }
const int N= 2e5+1;

void solve(){
  int a,b, s=0; cin>>a>>b;
  rep(i,b) {
    s=add(s,(mul(i,add(a,mul(b,divi(mul(a,a+1),2))))));
  }
  /*s=mul(s,b);
  rep(i,b) s=add(s,i);*/
  cout<<s;
}

int32_t main() {
  IOS
  int t=1;
  //cin>>t;
  while(t--) solve();
}

#include <iostream>

using namespace std;

#define m 1000000007

int main()
{
	long long  int a,b;
	cin>>a>>b;
	long long int sum=0;
	if(b!=1)
	{
		for(int i=1;i<=a;i++)
		{
			sum=(sum+((b*(b-1)/2)%m)*((i*b+1)%m))%m;
		}
	}
	cout<<sum<<endl;
	return 0;
}

/*
 * “Doktor! Are you sure this will work?!”
 * “Ha-ha! I have NO IDEA!”
 */

/*
 * short     2^15-1 ~ 3e4
 * int       2^31-1 ~ 2e9
 * long x86  2^31-1 ~ 2e9
 * long long 2^63-1 ~ 9e18
 */

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a,b) for (int a=0; a<b; ++a)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000007ll;
const int infty = numeric_limits<int>::max();
struct _{_(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}_;

int main() {
#ifdef FTEST
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    ll a, b;
    cin >> a >> b;

    ll s = 0;
    ll w = 0;
    for (ll k=1; k<=a; ++k) {
        w = (1+k*b); w %= mod;
        if ((b-1)%2) {
            w *= (b-1); w %= mod;
            w *= b/2; w %= mod;
        } else {
            w *= (b-1)/2; w %= mod;
            w *= b; w %= mod;
        }
        s += w;
        s %= mod;
    }
    if (s < 0) s += mod;
    cout << s << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
const int INF=2000000010;
const int INFLL=999999999999999999ll;
const long long MOD=1000000007;
map<long long,bool> nums;
typedef long long ll;
long long sum(ll lo,ll hi,ll howmany)
{
    //printf("%lld %lld %lld\n",lo,hi,howmany);
    ll mul1=(lo+hi);
    ll mul2=(hi-lo)/howmany+1;
    if(mul1%2==0) mul1/=2;
    else mul2/=2;
    mul1%=MOD;
    mul2%=MOD;
    return (mul1*mul2)%MOD;
}
int main()
{
    ll a,b;
    scanf("%lld%lld",&a,&b);
    ll sumkb1=sum(1,a,1)*b+a;
    sumkb1%=MOD;
    ll tomul=sum(1,b-1,1);
    tomul%=MOD;
    ll ans=sumkb1*tomul;
    ans%=MOD;
    printf("%lld\n",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define eb emplace_back
ll md=1e9+7;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
ll i,j,k,n,m=1,ans=0,a,b;
cin>>a>>b;
for(i=1;i<b;i++){
    // ans+=1+(a-1)*i;
    ans+=(i*a)%md+(((((a+a*a)/2)%md)*i)%md*b)%md;
    ans%=md;
}
cout<<ans<<"\n";
    return 0;
}

/*
 * socode.online
 *
 * Author: 任奕佳
 * E-mail: 1234567890@qq.com
 * Time  : 2019-12-13 19:39:14
 */
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long sum=0,a,b,m,tem;
    long long mod=1000000007;
    cin>>a>>b;
    m=(b-1)*b/2%mod;
    for(int i=1;i<=a;i++){
        tem=(i*b+1)%mod;
        sum=(sum+m*tem%mod)%mod;
    }
    cout<<sum<<endl;
    return 0;
}
	 		   	 	  	 	   	 		   	  	 	//hellobig_tq//hello//hello

#include <iostream>
#include <sstream>
#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;

#define INF 1000000007

long long a, b;

int main() {
    cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    for (long long i = 1; i < b; i++) {
        ans += (((((((a * (a + 1)) / 2) % INF) * i) % INF) * b) % INF + i * a) % INF;
        ans %= INF;
    }
    cout << ans << endl;
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <queue>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory>

using namespace std;

using vi = vector<int>;
using ii = pair<int,int>;
using ll = long long;
using llu = unsigned long long;
const int INF = numeric_limits<int>::max();

const ll MOD = 1000000007;

int main() {
  llu a, b;
  while (cin >> a >> b) {
    llu r = b * (b - 1) / 2;
    r %= MOD;
    llu x = a;
    llu y = b + 2 + a * b;
    if (x % 2 == 0) {
      x /= 2;
    } else {
      y /= 2;
    }
    x %= MOD;
    y %= MOD;
    r = (r * x) % MOD;
    r = (r * y) % MOD;
    cout << r << endl;
  }
}

#include<iostream>
using namespace std;
#define mod 1000000007

int main(){
    long long a,b;
    cin >> a >> b;
    cout << ((((b*b-b)/2)%mod)*(a+b*(((a*a+a)/2)%mod)%mod))%mod << endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <list>
#include <sstream>
#include <ctype.h>
#include <utility>
#include <cstdlib>
#include <functional>
#include <numeric>

using namespace std;

#define DEBUG(x) { cerr << #x << " = " << x << endl; }
#define ll long long
#define lINF 998877665544332211ll
#define INF 987654321ll
#define MOD 1000000007
#define ADD(v) accumulate(v.begin(),v.end(), 0)
#define PRO(v) accumulate(v.begin(),v.end(), 1,multiplies <int>())
ll POS(ll x) { if (x > 0)  return x; else return 0; }
#define maxe(v) max_element(v.begin(),v.end())
#define mine(v) min_element(v.begin(),v.end())
#define rep(k,a,b) for(int k=(a); k < (b); ++k)
#define per(k,a,b) for(int k=(b-1); k >= (a); --k)
int main() {
    ll a, b,res1 = 0,res2 = 0,res = 0,res3= 0;
    cin >> a >> b;
    res1 = ((b*(b - 1)) / 2) % MOD;
    res2 = ((a*(a + 1)) / 2) % MOD;
    res3 = ((res2*b) % MOD + a) % MOD;
    res = (res3*res1) % MOD;

    cout << res << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define pb push_back
typedef vector<int> vi;
typedef pair<int,int> pi;
#define mod 1000000007
#define fio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int modinv;
int power(int x,int y)
{  int res=1;
    while(y)
   {
       if(y&1)
       res=(res*x)%mod;
       x=(x*x)%mod;
       y/=2;
   }
   return res;
}
int sum(int a,int d,int n)
{return (n*((2*a%mod+(n-1)*d%mod)%mod)%mod)*modinv%mod;}
int32_t main() {
    fio;
    int a,b,ans=0;
    cin>>a>>b;
    modinv=power(2,mod-2);
    for(int i=1;i<b;i++)
    ans=(ans+sum((b*i+i)%mod,b*i%mod,a))%mod;
    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long lli;

typedef pair<int,int> pii;
typedef vector<int> vec;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
lli mod = 1e9+7;

lli sum(lli a){
	lli k =  (a*(a+1LL))/2LL;
	return k%mod;
}

int main(){
	lli a,b;
	cin>>a>>b;
	lli ans = sum(a);
	ans = (ans*b+a)%mod;

	ans = (ans * sum(b-1LL))%mod;
	cout<<ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a, b;
    long long ans = 0, mod = 1e9 + 7;
    cin >> a >> b;
    for(long long k = 1; k<b; ++k)
    {
        long long diff = b*k, first =2*(k*b+k), n=a-1, m =a;
        if(m%2ll)
            {
                first/=2;
                first%=mod;
                n/=2;
                n%=mod;
                diff%=mod;
                diff*=n;
                diff%=mod;
                diff+=first;
                diff%=mod;
                m%=mod;
                ans+=(m*diff)%mod;

            }

        else
          {
              m/=2;
              m%=mod;
              first%=mod;
              n%=mod;
              diff%=mod;
              diff*=n;
              diff%=mod;
              diff+=first;
              diff%=mod;
              ans+=(m*diff)%mod;
          }
        ans%=mod;
    }
    cout << ans%mod;
}

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
ll mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll ans=0;
    for(ll i=1;i<b;i++)
    {
        ll t1=(a*b+2+b);
        ll t2=(a*i);
        if(t1%2==0)
        {
            t1/=2;
        }
        else
        t2/=2;
        t1%=mod;
        t2%=mod;
        ans+=(t1*t2);
        ans%=mod;
    }
    cout<<ans;
}

#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

long long int safeAdd(long long int a, long long int b) {
    a += b;
    a %= MOD;
    return a;
}

long long int safeMult(long long int a, long long int b) {
    a *= b;
    a %= MOD;
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int a, b, ans, sm = 0;
    cin >> a >> b;
    for(int m = 1; m <= b - 1; m++) {
        sm = safeAdd(sm, m);
    }
    ans = a * (a + 1) / 2;
    ans %= MOD;
    ans = safeMult(safeMult(ans, b), sm);
    ans = safeAdd(ans, safeMult(sm, a));
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int md = 1000000007;

int sum(int n) {
  return ((n + 1LL) * n / 2) % md;
}

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d\n", (int)((b * 1LL * sum(a) + a) % md * sum(b - 1) % md));
  return 0;
}

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define ld long double
#define pi 3.1415926536
#define re return
#define mm(o,k) memset(o,k,sizeof o)
#define endl "\n"
#define hossam_yehia ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
ll power(ll x,ll y){
    ll res= 1;
    while(y){
        if (y&1)
            res*= x;
        x*=x;
        y>>=1;
    }
    return res;
}
ll bigmod(ll n,ll power,ll mod){
    if(!power)
        return 1;
    if(power%2==0){
        ll ret=bigmod(n,power/2,mod);
        return ((ret%mod)*(ret%mod))%mod;
    }
    else
		return ((n%mod)*(bigmod(n,power-1,mod)%mod))%mod;
}
ull a,b,cnt,hna,mod(1e9+7),sum,ba2e;
int main() {
	hossam_yehia;
	cin >> a >> b;
	sum=(a*(a+1))/2;
	for(ull i=1;i<b;i++){
        ba2e+=a;
        cnt+=(ba2e%mod);
        cnt%=mod;
        hna=i*b;
        cnt+=(((hna%mod)*(sum%mod)%mod));
        cnt%=mod;
	}
	cout<<cnt%mod<<endl;
	re 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
int main()
{
	ll n,i=0,m,j,a,b,k=0,ans;
	cin>>a>>b;
	ans=b*(b-1)/2;
	ans%=mod;
	k=a*(a+1)/2;
	k%=mod;
	k*=b;
	k%=mod;
	k+=a;
	ans*=k;
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<map>
#include<utility>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>

#define LL long long
#define ii pair<int,int>
#define MP make_pair
#define PB push_back
#define inf 2123123123
#define PI 3.14159265
#define MOD 1000000007
using namespace std;
int n,m,i,j;
LL a,b,ans;
int main(){
	a=b=ans=0;
	scanf("%I64d%I64d",&a,&b);
	LL ans2=0;
	LL tmp=1;
	for(LL i=1;i<=a;i++){
		tmp=(b+tmp)%MOD;
		ans2=(tmp+ans2)%MOD;
	}
	tmp=1;
	for(LL i=1;i<b;i++){
		LL t = (tmp*ans2)%MOD;
		ans = (ans+t)%MOD;
		tmp++;
	}
	printf("%I64d\n",ans);
	//cout<<ans2<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int M = 1e9 + 7;

int main()
{
    long long int a, b; cin >> a >> b;

    long long int bsum = ((b-1)*b)/2;
    bsum %= M;

    long long int sum = 0;

    for (int i = 1; i <= a; i++)
        sum = (sum + bsum*((i*b+1)%M))%M;

    cout << sum;

    return 0;
}

#include <iostream>
#define MOD 1000000007

using namespace std;

typedef long long int ll;

ll g(ll x) {
    return ((x*(x+1))/2)%MOD;
}

int main()
{
    ll a,b;
    cin>>a>>b;
    //ll res=(g(a)*b+a)*g(b-1);
    ll res=g(a)%MOD;
    res*=b; res%=MOD;
    res+=a;
    res*=g(b-1); res%=MOD;
    cout<<res;

    return 0;
}

#pragma warning(disable:4996)
#include<iostream>
#include<stdio.h>
#include<queue>
#include<string.h>
#include<set>
#include<map>
#include<string>
#include<stack>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<stdlib.h>
using namespace std;
const int MAX_N = 5005;
#define INF 0x3f3f3f3f
#define LL long long
typedef pair<int, int> PII;
#define MP make_pair
#define pb push_back
#define rep0(i,n) for(int i=0;i<n;i++)
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define clr(x,a) memset(x,a,sizeof(x))
#define lson l,m,,rt<<1
#define rson m+1,r,rt<<1|1
#define lowbit(x) (x)&(-(x))
const int N=1<<23;
int m,x,num,y;
const LL MOD=1000000007;
LL a,b,n;
int main()
{
    //cout<<((~0ULL)>>1)<<endl;;
   // freopen("aaa.txt", "r", stdin);
    //freopen("bbb.txt","w",stdout)
    int T;
    //scanf("%d",&T);

       while(~ scanf("%I64d%I64d",&a,&b)){
           // LL  tmp=(a*a-a*b-1)/a;
            if(b==1 ){
                puts("0");
                continue;

            }

            LL ans=0;
            LL tmp=(b*(b-1)/2)%MOD;
          //  cout<<((a*(1+a)/2))*b<<endl;
        //    cout<<(((a*(1+a)/2))*b)%MOD<<endl;
            LL t=(a+((a*(1+a)/2)%MOD)*b)%MOD;

            ans=(t*tmp)%MOD;
            printf("%I64d\n",ans);

       }

 return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<unordered_set>
#include<map>
#include<queue>
#include<set>
using namespace std;

bool * sieve()
{
	bool * arr =new bool[10000001];
	for(int i=0;i<10000000;i++)
		arr[i]=true;
	for(int i=2;i*i<10000000;i++)
	{
		if(arr[i])
		{
			for(int p = i*2; p<=10000000;p+=i)
				arr[p]=false;
		}
	}
	return arr;
}
struct Node
{
int data;
Node* next;
};
//Node *removeDuplicates(Node *root)
//{
// Node * current=root;
//
//}
//vector<int> find_all(string input, string to_find)
//{
//	vector<int> indices;
//	for(int i=0;i<input.size();i++)
//	{
//		bool flag=true;
//		if(input[i]==to_find[0])
//		{
//			flag=false;
//			for(int j=1;j<to_find.size();j++)
//			{
//				if(input[i+j] != to_find[j])
//				{
//					flag=true;
//					break;
//				}
//			}
//		}
//		if(flag == false)
//			indices.push_back(i);
//	}
//	return indices;
//}
bool is_plaindrom_number(long long number)
{
	long long reversed_number = 0;
	long long temp = number;
	while(temp > 0)
	{
		int reminder = temp % 10;
		reversed_number = (reversed_number * 10) + reminder;
		temp /= 10;
	}
	if ( number == reversed_number)
			return true;
	return false;
}
bool is_max(long long p, long long q, long long prims_count, long long plaindroms_count)
{
	if( q * prims_count <= p * plaindroms_count)
		return true;
	return false;
}
long long sum(long long n)
{
	long long temp = n * (n+1);
	temp /= 2;
	return temp;
}
int main()
{
	long long a,b;
	while(cin>>a>>b)
	{
		long long start, cons, total;
		total =0;
		cons = 1000000007 ;
		for(int i=1;i<=a;i++)
		{
			start = (i*b)+1;
			start %= cons;
			long long coff = 0;
			coff = sum(b-1);
			coff %= cons;
			start = coff * start;
			start %= cons;
			total +=start;
			total %= cons;
		}
		cout<<total % cons<<endl;
	}
	return 0;
}

#include <iostream>
using namespace std;
long long MOD=1e9+7;
int main()
{
    unsigned long long a,b,ans;ans=0; cin>>a>>b;
   unsigned long long sum = a*(a+1)/2;
   for(unsigned long long i=1;i<b;++i){
        ans = (  ( ans%MOD   +   ((i%MOD*b%MOD)%MOD*(sum%MOD))%MOD)%MOD  +   (i%MOD *a%MOD)%MOD)%MOD;
   }
    cout<<ans%MOD;
    return 0;
}

#include <stdio.h>
#include <iostream>

using namespace std;

const int mod = 1000000007;

long long A, B;
long long s1, s2, sol;

int main() {

    //freopen("in", "r", stdin);
    cin >> A >> B;

    s1 = 1LL * A * (A + 1) / 2 % mod;
    s2 = 1LL * B * (B - 1) / 2 % mod;
    sol = (1LL * s1 * B % mod + A) * s2 % mod;

    cout << sol % mod;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define all(t) t.begin(),t.end()
#define cen cout<<endl
#define _f first
#define _s second
#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define vi vector<int>
#define pii pair<int,int>

#define INFL LLONG_MAX
#define INFI INT_MAX

typedef long long ll;
typedef unsigned long long ull;

const int INF = 2000000000;
const double EPS = 1e-6;

#define file "name_of_file"
#define read1
ull a, b;
const ll mod = 1e9+7;
void solve()
{
    cin >> a >> b;
    ull ans(0);
    ull tmp = b*(b-1)/2;
    tmp %= mod;
    REPN(i, 1, a)
    {
        ans += (i*b+1);
        ans %= mod;
    }
    ans *= tmp;
    ans %= mod;
    cout << ans << endl;

}

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    #ifdef solved
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    #ifdef read
    freopen(file".in", "r", stdin);
    freopen(file".out", "w", stdout);
    #endif

    int t = 1;
    while(t--)
        solve();

	return 0;
}

/**
    हमने तुम्हे जिस सिद्दत से चाहा वो हम जानते हैं,
    पड़ जिसकी तुम हो उसके मोहब्बत की ताकत क्या रही होगी.
**/
/**

**/

#include <bits/stdc++.h>

#define ll                   long long
#define MOD                  (ll)(1e9 + 7)
#define INF                  (ll)1e18
#define fast()               ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define loop(i,a,b)          for(ll i=(ll)a;i<(ll)b;i++)
#define pool(i,a,b)          for(ll i=(ll)a;i>=(ll)b;i--)
#define pb                   push_back
#define vi                   vector<ll>
#define endl                 "\n"
#define param                greater<ll>()
#define ff                   first
#define ss                   second
#define all(v)               v.begin(),v.end()
#define dbg(x)               cout<<#x<<" is: "<<x<<endl;

using namespace std;

bool isvowel(char c){if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U')return true;return false;}

ll fast_exp(ll x,ll n){ll ans=1;while(n){if(n&1)ans*=x;n=n>>1;x=x*x;}return ans;}

ll mod_exp(ll x, ll y,ll p){ll res = 1;x = x % p;while(y>0){if(y&1)res = (res*x) % p;y = y>>1;x=(x*x)%p;}return res;}

ll sod(ll n){ll sum = 0;    while(n!=0){sum=sum+(n%10);n=n/10;}     return sum;}

ll modInverse(ll a, ll m){  return mod_exp(a, m-2, m);}

ll nCrModpDP(ll n,ll r,ll p)
{
    ll C[r+1];
    memset(C,0,sizeof(C));
    C[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for (ll j=min(i,r);j>0;j--)
            C[j]=(C[j]+C[j-1])%p;
    }
    return C[r];
}

ll nCrModpLucas(ll n,ll r,ll p)
{
    if(r==0)
        return 1;
    ll ni=n%p,ri=r%p;
    return(nCrModpLucas(n/p,r/p,p)*nCrModpDP(ni,ri,p))%p;

    //O(p2 * logp(n))
}

/*End of template */

ll compute(ll x,ll y,ll g)
{
	if(g%2==0)
		return ((x+y)%MOD)*(g/2)%MOD;
	return (((x+y)/2)%MOD*g)%MOD;
}

void solve()
{
    ll a,b;
    cin>>a>>b;
	ll ans=0;
	ll m=b*4;
	for(ll i=1;i<=m;i++)
	{
		ll s=i;
		ll h=a*i;
		ll res=compute(s,h,a);
		res=(res*b)%MOD;
		res=(res+i*a%MOD)%MOD;
		if(i<b)
			ans=(ans+res)%MOD;
	}
	cout<<ans<<"\n";

}

int main()
{

	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif

    fast()

    ll t;
    //cin>>t;
    t=1;
    while(t--)
        solve();

    #ifndef ONLINE_JUDGE
    	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif

}

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long int ll;
//const int mx=1e5+7;
//int n,m;
//vector<int> a(mx),b(mx);
// vector<int> g[mx];
// int deg[mx];
//vector<int> adj[mx];
//vector<int> ans;
//---dfs--
// bool visited[mx];
// vector<ll> val(mx,0);

// void dfs(int s,int e,int c1,int c2){
// 	if(a[s]^c1!=b[s]) {ans.push_back(s), c1^=1;}
// 	for(auto u:adj[s]){
// 		if(u!=e){
// 			dfs(u,s,c2,c1);
// 		}
// 	}
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];

// int spf[N];

// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int T=1;
	//cin>>T;
	while(T--){
		ll a,b;
		cin>>a>>b;
		ll m=(b*(b-1)/2)%MOD,n=(a*(a+1)/2)%MOD;
		ll temp=(n*b+a)%MOD;
		ll ans=(m*temp)%MOD;
		cout<<ans<<"\n";
 	}
}

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define ff first
#define ss second
#define mp make_pair
#define sqr(x) ((x)*(x))

typedef long long ll;
typedef pair <int, int> pie;

const int mod = 1000 * 1000 * 1000 + 7;

int a, b;

main() {
	ios::sync_with_stdio (false);

	cin >> a >> b;

	int A = (b - 1) * b / 2;
	int B = a + b * ((a * (a + 1) / 2) % mod);

	A %= mod, B %= mod;
	cout << A * B % mod << endl;

	return 0;
}

#include <math.h>
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <stdio.h>
using namespace std;
const int N=100005;
const long long MOD=1000000007;
long long a,b;
long long ans;
int main(){
    scanf("%lld%lld",&a,&b);
    long long ss=(b*(b-1))/2;
    for(long long i=1;i<=a;i++){
        ans+=( ( (ss%MOD)*( (1+(i*b)) %MOD))%MOD)%MOD;
        ans%=MOD;
    }
    printf("%lld\n",ans);

    return 0;
}

#include <stdio.h>
typedef long long ll;
const int mod = 1e9 + 7;
int main()
{
    ll a, b;
    scanf("%I64d%I64d", &a, &b);
    ll ans1 = b * (b - 1) / 2 % mod, ans2 = ((((a * (a + 1) / 2) % mod) * b) % mod + a) % mod;
    printf("%I64d", (ans1 % mod * ans2 % mod) % mod);
    return 0;
}
//2019-07-27 18:56:45.185

#include"iostream"
#include"vector"
#include"string"
using namespace std;

int main() {

    long long a, b;
    cin >> a >> b;
    long long ans = 0;

    long long d = (b*(b - 1)/2) % 1000000007;
    long long c = (a*(a + 1)/2) % 1000000007;
    ans = (c*b + a) % 1000000007;
    cout << (ans*d) % 1000000007;
}

#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
const int mod=1e9+7;

void open()
{
	freopen("sums.in","r",stdin);
	freopen("sums.out","w",stdout);
}

LL a,b,ans;

int main()
{
	//open();
	cin>>a>>b;
	ans=(b*(b-1)/2)%mod*((b*(((a+1)*a/2)%mod)+a)%mod);
	cout<<ans%mod<<endl;
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <string>
#include <cstring>
#include <string.h>
#include <time.h>
#include <bitset>
#include <limits.h>
#include <iomanip>

using namespace std;

int const mod = 1000000007;

int main()
{
	ios_base::sync_with_stdio(0);
	long long a,b;
	cin >> a >> b;
	long long sum=0;
	long long sq = (b*(b-1))/2;
	sq %= mod;
	for( long long k = 1; k <= a; k++ )
	{
		long long cur = (k*b+1)%mod;
		cur *= sq;
		cur %= mod;
		sum += cur;
		sum %= mod;
	}

	cout << sum;

	return 0;
}

#include <vector>
#include <queue>
#include <map>
#include <list>
#include <cmath>
#include <utility>
#include <queue>
#include <algorithm>
#include <limits>
#include <set>
#include <iostream>
#include <string>
using namespace std;

int main()
  {
  __int64 a, b;
  cin >> a >> b;

  __int64 a2 = (a*(a+1)/2) % 1000000007;
  __int64 ba2 = (b*a2) % 1000000007;

  __int64 ret=0;
  for (__int64 m=1; m<b; ++m)
    {
    __int64 tmp = m*(a + ba2);
    ret = (ret+tmp) % 1000000007;
    }

  cout << ret;

  return 0;
  }

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define mod 1000000007
ll a, b, sumi, sumj;

void add(ll &a, ll b)
{
	a = (a + b) % mod;
}

ll mul(ll a, ll b)
{
	return (a * b) % mod;
}

int main()
{
#ifdef DEBUG
	freopen("data.in", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);

	cin >> a >> b;
	ll ans = 0;
	for(ll j = 1; j <= b - 1; ++j)
		add(sumj, j);
	for(ll i = 1; i <= a; ++i)
		add(sumi, mul(i, sumj));
	ans = (mul(a, sumj) + mul(b, sumi)) % mod;
	cout << ans << endl;
#ifdef DEBUG
	printf("Time elapsed: %ld ms\n", 1000*clock()/CLOCKS_PER_SEC);
#endif
	return 0;
}

/**Bismillahir Rahmanir Rahim
   In the name of ALLAH, most gracious, most merciful */
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <complex>
#include <numeric>
#include <valarray>
#include <iostream>
#include <memory.h>
#include <algorithm>
using namespace std;
#define inf           (1<<29)
#define pb            push_back
#define mp            make_pair
#define eps           1e-9
#define nl            printf("\n")
#define spc           printf(" ")
#define sci(n)        scanf("%ld",&n)
#define sc64(n)       scanf("%I64d",&n)
#define scii(a,b)     scanf("%ld %ld",&a,&b)
#define sc6464(a,b)   scanf("%I64d %I64d",&a,&b)
#define scs(s)        scanf("%s",s)
#define scss(a,b)     scanf("%s %s",a,b)
#define scd(f)        scanf("%lf",&f)
#define scdd(a,b)     scanf("%lf %lf",&a,&b)
#define prc(k)        printf("Case %ld: ",k);
#define pri(a)        printf("%ld",a)
#define pr64(a)       printf("%I64d",a)
#define prii(a,b)     printf("%ld %ld",a,b)
#define pr6464(a,b)   printf("%I64d %I64d",a,b)
#define prs(a)        printf("%s",a)
#define prss(a,b)     printf("%s %s",a,b)
#define prd(a)        printf("%lf",a)
#define prdd(a,b)     printf("%lf %lf",a,b)
#define rep(i,n)      for(int i(0),_n(n);i<_n;++i)
#define repr(i,n)     for(int i=n;i>=0;i--)
#define repi(i,a,b)   for(int i(a),_b(b);i<=_b;++i)
#define repl(i,n)     for(int i(1),_n(n);i<=_n;++i)
#define repir(i,a,b)  for(int i=a;i>=b;i--)
#define chk(a,k) ((bool)(a&(1<<(k))))
#define off(a,k) (a&(~(1<<(k))))
#define on(a,k) (a|(1<<(k)))
#define ff            first
#define ss            second
#define all(a)        a.begin(),a.end()
#define mem(x,a)      memset(x,a,sizeof(x))
#define repe(it,c)    for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
int dx[]={0,0,1,-1,1,-1,1,-1},dy[]={1,-1,0,0,1,-1,-1,1};
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#define ll long long
typedef vector<vector<int> > vvi;
inline void cn( long &n )//fast input function
{
n=0;
long ch=getchar();int sign=1;
while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}
while(ch >= '0' && ch <= '9')
n = (n<<3)+(n<<1) + ch-'0', ch=getchar();
n=n*sign;
}
template<class T> void cmin(T &a,T b){if(b<a) a=b;}
template<class T> void cmax(T &a,T b){if(b>a) a=b;}
template<class T> int len(const T&c){return (int)c.size();}
template<class T> int len(char c[]){return (int)strlen(c);}
string itos(long n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
long stoi(string s){long n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}

//Polya-Burnside theory : (n^6+3n^4+12n^3+8n^2)/24
#define DEBUG 1
#if DEBUG && !ONLINE_JUDGE
	#define debug(args...) (Debugger()) , args
	class Debugger { public: Debugger(const std::string& _separator = ", ") : first(true), separator(_separator){} template<typename ObjectType> Debugger& operator , (const ObjectType& v) { if(!first) std::cerr << separator; std::cerr << v; first = false; return *this; } ~Debugger() { std::cerr << endl;} private: bool first; std::string separator; }; template <typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; } template<typename T> inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v) { bool first = true; os << "["; for(unsigned int i = 0; i < v.size(); i++) { if(!first) os << ", "; os << v[i]; first = false; } return os << "]"; } template<typename T> inline std::ostream &operator << (std::ostream & os,const std::set<T>& v) { bool first = true; os << "["; for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii) { if(!first) os << ", "; os << *ii; first = false; } return os << "]"; } template<typename T1, typename T2> inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v) { bool first = true; os << "["; for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii) { if(!first) os << ", "; os << *ii ; first = false; } return os << "]"; }
#else
		#define debug(args...)
#endif
#define mod 1000000007

int main()
{

   long long a,b,aa,bb,r1,r2,s,k;

   while(cin>>a>>b){

       // cout<<((((((a*(a+1)/2)%mod)*b)%mod) * (b*(b-1)/2)%mod) % mod + ((b*(b-1)/2)%mod * a)%mod)%mod;
        s = a*(a+1)/2 % mod;
        s = (s*b)%mod;
        s = s * (b*(b-1)/2 % mod) %mod;

        k = (b*(b-1)/2 % mod);
        k = (k * a) % mod;

        cout<<(s+k)%mod<<endl;

   }

return 0;
}

#include <cmath>
#include <climits>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cassert>
using namespace std;;
#define rep(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define dwn(i,n) for(int i=(n); --i>=0; )
#define repr(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define dwnr(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(auto i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(auto i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define smin(a,b) a=min(a,b)
#define smax(a,b) a=max(a,b)
#define inf INT_MAX
#define eps 1e-9
#define pi 3.1415926535897932384626
#define vec vector
#define all(c) bgn(c),end(c)
#define szo(c) sizeof(c)
#define asz(c,p) sizeof(c)/sizeof(p)
#define sz(c) (c).size()
#define end(c) (c).end()
#define bgn(c) (c).begin()
#define lst(c) (c[sz(c)-1])
#define has(a, b) (find(all(a)) != a.end())
#define hasc(a,b) ((a).find(b)!=(a).end())
#define pb push_back
#define mp make_pair
#define zro(c) memset(c,0,sizeof(c))
#define neg(c) memset(c,-1,sizeof(c))
#define ord(a,b) do{if(a>b)swap(a,b);}while(0);
#define bit(c,i) ((c>>i)&1)
#define dbg(a...) do{cerr<<#a<<" = ";_d,a;cerr<<endl;}while(0)
#define big long long
#define pr pair
#define pii pr<int, int>
#define vi vec<int>
#define str string
#define bigf long double
#define ff first
#define ss second
#define ios ios_base::sync_with_stdio(0)
#define pt complex
#define mine(c...) min_element(c)
#define maxe(c...) max_element(c)
#define pti pt<int>
#define xx real
#define yy imag
#define bin binary_search
#define lb lower_bound
#define ub upper_bound
#define msi map<string, int>

struct _dbg{
	template<class T> _dbg& operator,(const T& v){
		cerr<<v<<" ";
		return *this;};};
_dbg _d;
const big M = 1e9+7, K = 250000002;

int main(){
	big a,b;cin>>a>>b;
	cout<<K*a%M*(b-1)%M*b%M*((a*b%M+b)%M+2)%M;};

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;
const long long MOD = 1000000007 ;
long long a,b,ans;
long long b1,a1,bb,aa;
long long q,r,k;
// x qb+r
int main()
{
    cin>>a>>b;
    bb=b%MOD; aa=a%MOD;

    if(!(b%2)) { b1=b/2; b-=1; }
    else b1=(b-1)/2;
    b1%=MOD; b%=MOD;
    r = b*b1;
    r=r%MOD;
    if(!(a%2)) { a1=a/2; a+=1; }
    else a1=(a+1)/2;
    a1%=MOD; a%=MOD;
    k = a*a1;
    k=k%MOD;

    ans = r * (( (bb*k)%MOD + aa)%MOD );
    ans=ans%MOD;
    cout<<ans<<endl;
    return 0;
}

#include <iostream>

using namespace std;

constexpr unsigned long long mod {1000000007};

inline void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    unsigned long long a;
    unsigned long long b;

    cin >> a >> b;

    cout << ((a * (a + 1) / 2 % mod * b % mod + a) * (b * (b - 1) / 2 % mod)) % mod;

    return 0;
}

#include <bits/stdc++.h>

#define INF 1000005
#define FOR(i, a, b) for(int i=int(a); i<int(b); i++)
#define pb push_back
#define endl '\n'
#define PI 3.14159265358979323846
#define fst first
#define snd second

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define MOD 1000000007
#define maxN 1005
#define EPS 0.00009
#define LSOne(S) (S & (-S))

ll n, m, k, y, a, b, c;
ll A[maxN], B[maxN], C[maxN];

int main() {

    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> a >> b;
    ll c = a;

    a = (a*(a+1)/2) % MOD;
    a = (a*b+c) % MOD;
    b = (b*(b-1)/2) % MOD;

    a = (a*b)%MOD;

    cout<<a<<endl;

}

#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
using namespace std;

long long i,j,k=1000000007,p,l,m,n,a,b;
int main()
{
    cin>>a>>b;
    cout<<(((((a+1)*a)%k*b/2)%k+a)%k*(((b-1)*b/2)%k))%k;
}

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
long long ans,sum;
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	sum=((a-1)*a*b)*(b-1);
	sum/=2;
	for(int i=1;i<b;i++){
		sum+=(b*i+i)*a;
	}
	cout<<sum;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 998244353;//1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e2+5;
int add(int a,int b)
{
      a+=b;
      if(a>=MOD) a-=MOD;
      return a;
}
int sub(int a,int b)
{
      a-=b;
      if(a<0) a+=MOD;
      return a;
}
int mul(int a,int b)
{
      return ((long long)a*b)%MOD;
}
int rev(int a)
{
	return mpow(a,MOD-2);
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	// freopen("output.txt","w",stdout);
	#endif
	int a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=0;i<b;i++)
	{
		// int l=i;
		int k=i;
		int l=k;
		int r=a*k;
		r%=MOD;
		int n=a*k-k+1;
		n%=MOD;
		int an=mul(n,add(add(k,mul(b,l)),add(k,mul(b,r))));
		// cout<<an<<"\n";
		an=mul(an,rev(2));
		// cout<<an<<"\n";
		ans=add(ans,an);
	}
	cout<<ans;
}
// k<=k/b+o<=a*k
//
// k+(b)*(k)...k+(b)*(a*k)
// n/2(k+bk+k+b*a*k)
//
// 1<=(x/b)/(x%b)<=a
// k<=(x/b)<=a*k
//
// (x/b)/(x%b)=k
// (x/b)=k*(x%b)
// x=(x/b)*b+x%b
// x*k=(x/b)*b*k+x/b
// x*k=(b*k+1)*(x/b)
//
// x=(k*b+1)*(x%b)
// x/(x%b) =
// x=(x/b)*b+x%b
// x/(x%b)-1=(x/b)/(x%b)*b
//
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    long long a,b;
    while(~scanf("%lld%lld",&a,&b))
    {
        long long sum=0;
        if(b==1){printf("0\n");}
        else{
            for(long long i=1;i<=a;i++)
            {
                long long x=b;
                while(x!=(x%b)*(i*b+1)) x++;

                sum+=x%1000000007;
            }
            printf("%lld\n",sum%1000000007);
        }

    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long

const int MOD=1e9+7;

int32_t main(){
    int a,b;cin>>a>>b;
    int sum=0;
    for(int i=1;i<=a;i++)  sum=(sum+i)%MOD;
    int ans=0;
    for(int i=1;i<b;i++) ans=((ans+ (a*i)%MOD)%MOD + (i*(b*sum)%MOD)%MOD)%MOD;
    cout<<ans<<"\n";
    return 0;
}

#include<cstdio>
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<iostream>
#include<math.h>
#include<memory.h>
#include<string>
#include<queue>
#include<set>
#define mod 1000000007
using namespace std;
typedef long long ll;
struct str {
	int x, y;
	bool operator < (const str& A)const {
		return x < A.x;
	}
};
string s1, s2;
int n, m, k, arr[100010];
int main() {
	scanf("%d %d", &n, &m);
	ll sum = 0;
	ll pre = 0;
	for (int i = 1; i <= n; i++) {
		pre = (pre + i) % mod;
	}
	pre = (pre * m) % mod;
	for (ll i = 1; i < m; i++) {
		sum = (sum + pre) % mod;
		sum = (sum + ((i * n)%mod)) % mod;
	}
	printf("%lld", sum);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long       ll;

#define all(x)            (x).begin(),(x).end()
#define Sort(x)            sort(all(x))
#define A               first
#define B               second
#define sep             ' '
#define fast_io         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random     mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count())

const ll MAX1 = 5e3+10,
         MOD = 1e9+7;

ll n, a, b, ans;

int main(){
    fast_io;
    cin >> a >> b;
    for (ll i = 1; i < b; ++i){
    	ans += i*a + (a*(a+1)/2%MOD)*b;
    	ans %= MOD;
	}
	cout << ans;
    return 0;
}
/*                 now or never                 */

#include <iostream>
#include <string>
#include <ctime>
#include <cstring>
#include <deque>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#define ll long long
#define fname ""
#define F first
#define S second
#define mp make_pair
#define pb push_back

using namespace std;

const ll mod = (ll) 1e9 + 7;

const int N = 1;

ll ans, a, b;

int main ()
{
//	freopen (".out", "w", stdout);
	cin >> a >> b;
	ll k = (((a + 1) * a) / 2) % mod;
	for (int i = 1;i < b;i ++)
		ans = (ans + (k * b) % mod + (a * i) % mod) % mod;
	cout << ans % mod;
	return 0;
}

#include<iostream>
using namespace std;
int a,b,i;
long long ans=0,val=0;
int main(){
	cin>>a>>b;
	if(b==1)
		cout<<"0"<<endl;
	else{
		for(i=1;i<=a;i++)
			ans+=i*b+1;
		for(i=1;i<=b;i++){
			val=(val+ans*i)%1000000007;
		}
		cout<<val<<endl;

	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define frl(a, b, c) for( (a) = (b);( a) < (c); (a++))
#define fru(a, b, c) for( (a) = (b); (a) <= (c); (a++))
#define frd(a, b, c) for( (a) = (b); (a) >= (c); (a--))
#define mst(a, b) memset(a, b, sizeof(a))
#define si(a) scanf("%d", &a)
#define ss(a) scanf("%s", a)
#define sc(a) scanf("%c", &a)

#define pb(a) push_back(a)
#define mp make_pair
#define nwl puts("");
#define sp << " " <<

#define sz size()
#define bg begin()
#define en end()
#define X first
#define Y second

#define vi vector <int>
#define vs vector <string>
#define ll long long int
#define dec int i = 0, j= 0, k = 0;

#define i(n) cin >> n;
#define p(s) cout << s;
#define pau system("pause");

int n, ans;
string s1, s2;
int c1, c2;
void f(int pos, int cnt){
    if(pos == n){
        if(cnt == c1)
            ans += 1;
        return;
    }
    if(s2[pos] == '+')
        f(pos+1, cnt+1);
    else if(s2[pos] == '-')
        f(pos+1, cnt-1);
    else{
        f(pos+1, cnt+1);
        f(pos+1, cnt-1);
    }
}

#define mod 1000000007

int main()
{
    ll a, b;
    cin >> a >> b;
    dec;
    cout << ((a + ((((b*a)%mod)*(a+1))%mod)/2LL) * ((((b-1)*b)/2LL)%mod));

}

#include <bits/stdc++.h>

using namespace std;

#define DEBUG_ON 0

#define INF 0x3f3f3f3f
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)
#define R(x) scanf(" %d",&x)
#define DBG(x) if(DEBUG_ON) cout << #x << " == " << x << endl

typedef long long ll;
#define MOD 1000000007LL

typedef pair<ll,ll> ii;

ii mdc(ll a, ll b){
  if (b == 0) return ii(1,0);
  ii u = mdc(b,a%b);
  return ii(u.second, u.first - (a/b)*u.second);
}

ll invmod(ll a, ll M = MOD) {
  ii r=mdc(a,M);
  if (r.first * a + r.second * M == 1)
    return (r.first + M) % M;
  return 0;
}

ll a, b;
int main() {
  scanf(" %lld %lld",&a,&b);
  ll ans = 0LL;
  ll inv2 = invmod(2)%MOD;
  DBG(inv2);
  for (ll r = 1LL; r <= b - 1; r++) {
    if (r > a) continue;
    ll ln = ((a/r)*r)%MOD;
    ll n = (a/r);
    if (ln < r) continue;

    ll a1 = (r*b + r)%MOD;
    ll an = (ln*b + r)%MOD;

    ll x = (a1 + an)%MOD;
    x = (x*n)%MOD;
    x = (x*inv2)%MOD;
    ans = (ans + x)%MOD;
  }
  printf("%lld\n",ans);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5+10;
const int MOD = 1e9+7;
typedef long long LL;
LL qmod(LL a,LL b) {
    LL res=1;
    while(b>0) {
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
LL get_rev(LL x) {
    return qmod(x,(LL)(MOD-2));
}
int main() {
    LL a,b;
    LL res;
    while(scanf("%I64d %I64d",&a,&b)==2) {
        res=0;
        LL ff=get_rev(2);
       // printf("%I64d\n",ff);
        for(LL i=1;i<b;i++) {
            LL x=i; LL y=i*a;
            LL t=(y-x+1)%MOD;
            LL first=x*b%MOD; LL last=y%MOD*b%MOD;
            LL mm=((t)%MOD*(first+last)%MOD*(ff)+t*i%MOD+MOD)%MOD;
            res=(res+mm+MOD)%MOD;
        }
        printf("%I64d\n",res);
    }
    return 0;
}

#include <cstdio>

using namespace std;

typedef long long llint;

const int MOD = 1000000007;

int a, b;

int main(void) {

	scanf("%d%d", &a, &b);

	llint term1 = (llint)a*(a+1)/2 % MOD;
	term1 = term1*b % MOD;
	term1 = term1 * ((llint)b*(b-1)/2 % MOD) % MOD;

	llint term2 = b*(b-1)/2 % MOD;
	term2 = term2*a % MOD;

	printf("%lld\n", (term1+term2)%MOD);

	return 0;

}

#include <iostream>
using namespace std;

int main()
{
    // your code goes here
    long long int i,a,b,m=1000000007,ans=0;
    cin>>a>>b;
    for(i=1;i<=a;i++)
        ans += ((i*b)%m+1)%m;

    cout<<ans<<"\n";

    return 0;
}

// CF #272 pC
#include <cstdio>
#include <cstring>
#include <algorithm>
#define SZ(x) (int)((x).size())
using namespace std;
typedef long long LL;
#define MOD 1000000007
int main ()
{
    LL a,b; scanf("%I64d%I64d",&a,&b);
    LL ans=0;
    for ( LL i=1; i<b; i++ ) {
        LL tmp=(b*((i+(i*a)%MOD)*a)/2LL%MOD+i*a)%MOD;
        ans=(ans+tmp)%MOD;
    }
    printf("%I64d\n",ans);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull ;

const ull Mod = 1e9 + 7 ;

ull a,b,c,res = 0;

vector<ull> v ;

int main()
{
    ios_base :: sync_with_stdio(false);

    cin >> a >> b ;

    if(b == 1)
        return cout << 0 , 0 ;

    c = b+1 ;

    while(1)
    {
        if(c%b)
        {
            if((c/b)/(c%b) >= 1 && (c/b)/(c%b) <= a)
            {
                res += c % Mod;
                res = res % Mod;
                c++;
            }
            else
                break;
        }
        else
            c++;
    }

    cout << res ;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long int ll;
//const int mx=1e5+7;
//int n,m;
//vector<int> a(mx),b(mx);
// vector<int> g[mx];
// int deg[mx];
//vector<int> adj[mx];
//vector<int> ans;
//---dfs--
// bool visited[mx];
// vector<ll> val(mx,0);

// void dfs(int s,int e,int c1,int c2){
// 	if(a[s]^c1!=b[s]) {ans.push_back(s), c1^=1;}
// 	for(auto u:adj[s]){
// 		if(u!=e){
// 			dfs(u,s,c2,c1);
// 		}
// 	}
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];

// int spf[N];

// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int T=1;
	//cin>>T;
	while(T--){
		int a,b;
		cin>>a>>b;
		ll m=(b*(b-1)/2)%MOD,n=(a*(a+1)/2)%MOD;
		ll temp=(n*b+a)%MOD;
		ll ans=(m*temp)%MOD;
		cout<<ans<<"\n";
 	}
}

#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <string>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <complex>
#include <ctime>
#include <iterator>

using namespace std;

#define Long long long
#define ULL unsigned long long
#define MOD 1000000007
#define MAXN 2000000
#define EPS 0.0000001
//const double PI = acos(-1);

int main(){

	ULL a, b;
	cin >> a >> b;

	ULL c = min(a, b);
	ULL x = (c * (c - 1)) / 2;
	x = x % MOD;
	x = (x * a) % MOD;

	ULL y = (c * (c - 1)) / 2;
	y = y*a;
	y = y + (c * (c - 1)) / 2;
	y = y * a;
	y = (y / 2) % MOD;
	y = (y * b) % MOD;
	ULL ans = x + y;
	ans = ans % MOD;

	cout << ans << endl;

}

#define _CRT_SECURE_NO_WARNINGS

#include <string>
#include <sstream>
#include <cstring>
#include <sstream>
#include <vector>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <ctime>
#include <cmath>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <iomanip>
using namespace std;

#define pp system("pause");
#define ct double ttme = clock()
#define p_ct cout << (clock() - ttme) / CLOCKS_PER_SEC << endl
#define all(c) (c).begin(),(c).end()
#define fft ifstream fin("input.txt"); ofstream fout("output.txt")
#define fft_c FILE *fin, *fout
#define fft_c_open fin = fopen("input.txt","r"); fout = fopen("output.txt","w")
#define fft_c_cl fclose(fin); fclose(fout)
#define pii pair<ll,ll>
#define pff pair<float,float>
#define piii pair<int,pair<int,int>>
#define M_PI 3.14159265358979323846
typedef unsigned long long ull;
typedef signed long long ll;
const int INF = 1e9;
const int MAXM = 1000000007;
const int MAX = 1e7;
const int des = 10000;

const int maxn = 5005;

int main()
{
	ll a, b, ans = 0;
	cin >> a >> b;

	for(ll i = 1; i < b; i++) {
		ans += i * (((a + 1) * a) / 2) * b + i * a;
		ans %= 1000000007;
	}

	cout << ans << endl;

	//pp;
}

#include <bits/stdc++.h>
using namespace std;

#define F(i,n) for(int i=0;i<n;i++)
#define FE(i,n) for(int i=0;i<=n;i++)
#define FR(i,n) for(int i=n;i>0;i--)
#define FRE(i,n) for(int i=n;i>=0;i--)
#define mp(a,b) make_pair(a,b)
#define pii pair <int, int>
#define pb push_back
#define ft first
#define sd second
#define LL long long
#define gc getchar_unlocked
#define pc putchar_unlocked
#define get(Z) scanf("%d",&Z);

int main()
{
	int mod = 1e9+7;
	int a,b;
	get(a);
	get(b);
	LL ct = 0,div;
	for (LL i=1; i<b; i++)
	{
		div= a/i;
		ct += div + b*(div*(div+1))/2;
		ct %= mod;
	}
	printf("%lld",ct);
	return 0;
}

 #include <iostream>
 #include <string>
 #include <algorithm>
 #include <cstdio>
 #include <cstring>
 #include <stdio.h>
 #include <stdlib.h>
 #include <vector>
 #include <math.h>
 #include <set>
 #include <ctime>

using namespace std;

int main()
{
    long long ans = 0;
    int a, b;
    cin >> a >> b;
    for (int i = 2; i <= 10000000; ++i)
    if (i % b)
            if (i / b % (i % b) == 0)
                if (i / b / (i % b) <= a && i / b / (i % b) >= 1)
                    ans += i;
    cout << ans % 1000000007;

}

#include <bits/stdc++.h>

using namespace std;

const int M = 1e9+7;
int main ()
{
	long long a,b; cin>>a>>b;
	long long cnt = 0;
	for(int i = 1;i < b;i++)
	{
		long long inicial = (b+1)*i;
		long long  final = inicial + (i*a-1)%M*b;
		cnt += ((a*i)%M*(inicial + final)/2)%M;
		cnt %= M;
	}
	cout << cnt<<endl;
}

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<climits>
#include<cstring>
#include<list>
#include<fstream>
#include<queue>
#include<sstream>
#include<stack>
#include<iomanip>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

LL mod=1e9+7;

LL gcd(LL a, LL b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

int main()
{

     ios_base::sync_with_stdio(false);
     cin.tie(0);

     LL a, b;
     cin>>a>>b;

     LL ctr=b+1;

     LL ret=0;

     while(ctr<2*b+2)
     {
         if(ctr%b==0)
            {
                ctr++;
                continue;
            }

         LL t2= ctr;

         set <LL> mods;

         LL g= gcd(ctr, b);

         while(mods.count(t2%b)==0)
         {
             LL m= t2%b;

             if(mods.count(m)==1)
                break;

             mods.insert(m);

             if(m==0)
             {
                 t2+=ctr;
                 continue;
             }

             LL temp=t2;

                 while((temp/b)/(temp%b)<=a)
                 {
                     ret+=temp;
                     ret%=mod;

                     temp+= (b/g)*ctr;
                 }

             t2+=ctr;
         }

          ctr++;

     }

     cout<<ret;

}

#include <iostream>

using namespace std;

typedef long long ll;

long long a, b, base = 7+1e9, s = 0;
long long l = 0;

int main()
{
    cin>>a>>b;
    long long pr = (b-1)*b/2 % base;
    for (int  k=1;k<=a;k++)
//    {
//        s+=(long long) pr*k*b+pr;
//        s%=base;
//    }
    s = (ll) pr*a;
    s %= base;
    s*=(ll) b*(1+a)/2+1;
    s%=base;
    cout<<s;
    return 0;
}

//(pr*b+pr+pr*b*a+pr)/2*a
//pr(b+1+a*b+1)/2*a

#if 1
#include <iostream>
#include <vector>
#include <string>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <locale>

using namespace std;
#define PROBLEM "problem"
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
#define X first
#define Y second

const int INF = 1000 * 1000 * 1000;
const LL INF64 = 1LL * INF * INF;
const LL mod = INF + 7;

int ans[1000001] = {};

void solve()
{
	int a, b;
	cin >> a >> b;
	cout << (b*(b - 1) / 2)*((a + 1)*a*b / 2 + a) << endl;
}

int main()
{
	//freopen(PROBLEM".in", "r", stdin); freopen(PROBLEM".out", "w", stdout);
	//freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);

	cout.sync_with_stdio(false);
	//cout.precision(10);
	//cout.setf(ios::fixed);
	solve();

	return 0;
}
#endif

#include <stdio.h>

const int mod = 1000000007;

int A, B;
long long sol;

int main() {

    scanf("%d%d", &A, &B);

    sol = (1LL * A * ( A + 1 ) / 2 * B + A) * 1LL * B * (B - 1) / 2;

    printf("%d\n", sol % mod );

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000009
int32_t main()
{
	fast;
	int a, b;
	cin >> a >> b;
	int su = 0;
	int ex = ((b - 1) * b) / 2;
	ex %= mod;
	ex *= b;
	ex %= mod;
	int p = (a * (a + 1)) / 2;
	p %= mod;
	p++;
	p %= mod;
	su = p * ex;
	su %= mod;
	cout << su;
	// for (int i = 1; i <= a; i++)
	// {

	// 	ex *= (i * b + 1);
	// 	ex %= mod;
	// 	su += ex;
	// 	su %= mod;
	// }
	// cout << su;

}

#pragma comment (linker, "/STACK:10000000000")

#include <vector>
#include <fstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <queue>
#include <algorithm>
#include <stack>
#include <map>
#include <string>

#define INF 1000000009
#define INFl 1000000000000000007
#define ll long long
#define mp make_pair
#define pb push_back

using namespace std;

	ll a, b, ans = 0;

int main(){
//	ifstream in ("input.txt");
	cin >> a >> b;
	for (int k = 1; k <= a; k++){
		ans += (b * k + 1) * (b - 1) * (b) / 2;
	}
	cout << ans;
}

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <cstdlib>
using namespace std ;
const int lim = 100005 ;

int main() {
    long long A, B ;
    long long res = 0LL ;
    long long mod = 1000000007LL ;

    cin >> A >> B ;

    for( long long k=1LL; k<A && k<B; k++ ) {
	long long N = A/k ;
	res += (N*k)%mod ;
	res %= mod ;
	N = (N*(N+1LL))/2LL ;
	N %= mod ;
	res += (B*N)%mod ;
	res %= mod ;
    }

    cout << res << endl ;

    return 0 ;
}

#include <iostream>

using namespace std;

const int m = 1000000007;

int main() {
	int a, b;
	cin >> a >> b;
	long long ans = 1;
	ans = ans * b * (b-1) / 2;
	ans %= m;
	ans *= (a + b * a * (1+a) /2);
	cout << ans % m << endl;
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#define pb push_back
#define mp make_pair
#define ll long long
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define MOD 1000000007

using namespace std;
int a,b;

int main() {
    scanf("%d%d", &a, &b);
    ll ans = 0;
    for(int md = 1; md < b; md++) {
        // x = q*b+r
        // k = q/r -> r <= q
        //         -> ra >= q

        ll start = md, end = (ll)md*a;

        ll sum = (start+end)*(ll)a/2;
        ans += (ll)b*(sum%MOD);
		ans %= MOD;
		ans += end%MOD;
        ans %= MOD;
    //    1..a

    }
    printf("%I64d\n", ans);
    return 0;
}

#include <bits/stdc++.h>
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define N 100010
#define F first
#define S second

using namespace std;

long long a, b, s = 0;

int main()
{
    //file;
    cin >> a >> b;
    if (b < 2)
    {
        cout << s;
        return 0;
    }
    for (long long i = 1; i <= a; i++)
        s = (s + 1ll*(b*i + 1)) % (1ll*1000000007);
    if (s == 0) cout << 1000000007;
    else cout << s;
}

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) int(a.size())
#define reset(a, x) memset(a, x, sizeof(a))

#define FOR(i, a, b)   for(int i = a; i <= b; ++i)
#define FORD(i, a, b)  for(int i = a; i >= b; --i)
#define REP(i, n)      for(int i = 0, _n = n; i < _n; ++i)
#define REPD(i, n)     for(int i = n - 1; i >= 0; --i)
#define FORSZ(i, x)    for(int i = 0; i < sz(x); ++i)

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pii> vii;

int main(){
	// freopen("INPUT.INP","r",stdin);
	// freopen("OUTPUT.OUT","w",stdout);
	ll a, b;
	ll base = 1000000007;
	scanf("%I64d%I64d", &a, &b);
	ll ans = 0;
	FOR(i, 1, b - 1){
		ll x = b * i + i;
		ll y = b * a * i + i;
		ans += (((y - x) / (b*i) + 1) * ((y - x) / (b*i) + 2) / 2  * (b*i) + ((y - x) / (b*i) + 1) * i) % base;
	}
	printf("%I64d", ans);
}

#include<iostream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    long long a,b;
    cin >> a >> b;
    long long prodB=(b*(b-1))/2,prodA=(a*(a+1))/2;
    cout << (a*prodB + b*prodA*prodB) % 1000000007;
}

/*BISMILLAH
THE WHITE WOLF*/

#include<bits/stdc++.h>
using namespace std;

#define io ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define mod 1000000007
#define pii pair<int, int>

int main()
{
    io;
    int a, b;
    cin>> a>> b;
    ll sum = 0;
    ll s = ((a*(a+1))/2)%mod;
    for(int i = 1; i < b; i++)
        sum = (sum + (i*a)%mod + (s*i*b)%mod)%mod;
    cout << sum;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    long long a,b,c=0;
    cin>>a>>b;
    if(b == 1){
        cout<<0;
    }
    else{
        for(int i=1;i<b;i++){
            for(int j=1;j<=a;j++){
                c+=i*(1+b*j);
            }
        }
                cout<<c<<"\n";
    }
    return 0;
}

#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <cmath>
#include <vector>
#include<cctype>
#include<algorithm>
#include<set>
#include<stack>
#include<map>
#include<stdlib.h>
#include<ctime>
#include<iterator>
#include <deque>
#include <sstream>
#include<queue>
#include<cstdlib>
#include<climits>
#define ll long long

using namespace std;
ll a,b;

ll getDiff(ll n1,ll n2){
	return( (n2* (n2 + 1) / 2) - (n1 * (n1+1) /2));
}

bool modulo(ll n1,ll n2){
	stringstream ss,ss2;
	string s;
	ss<<n1;
	ss>>s;
	int mod = (s[0] - '0') % n2;
	for(int i = 1;i < s.size();i++){
		mod = (mod * 10 + s[i] - '0')% n2;
	}
	return mod;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin>>a>>b;

	ll sum = 0;
	for(ll i = 1;i <= a;i++ ){
		if(modulo(b * i + i,a))
			sum += getDiff(b * i,b * i+i);
		else sum += getDiff(b * i,b * i+i - 1);
		//cout<<b * i <<" "<<b * i+a <<" "<<sum<<endl;
	}
	ll l = 1,r = a;
	for(ll i  = (a+1) * b ;i < b * (b+1);i += b){
		sum += getDiff(i + l ,i + r);
		r++,l++;
	}

	cout<<1LL * sum<<endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cassert>
#include <map>

using namespace std;

long long ans = 0;

int main() {
	long long a, b; cin >> a >> b;

	for (long long c = 1; c < b; c++) {
		long long l = -b + c, r = b * 1e8 + c;
		while (r - l > 1) {
			long long m = (l + r) / 2;
			long long p = m * b + c;
			if (p / b >= c)
				r = m;
			else
				l = m;
		}
		long long k1 = r;
		l = c, r = b * 1e8 + c;
		while (r - l > 1) {
			long long m = (l + r) / 2;
			long long p = m * b + c;
			if (p / b <= a * c)
				l = m;
			else
				r = m;
		}
		long long k2 = l;
		if (k2 >= k1) {
			long long sum = ((k2 + 1) * k2 / 2 - (k1 - 1) * k1 / 2) * b + (k2 - k1 + 1) * c;
			ans += sum;
		}
	}

	cout << ans << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int sgm[10000010];

#define DSY 1000000007

void init(){
    for(int i=1;i<=10000000;i++){
        sgm[i] = (sgm[i-1]+i)%DSY;
    }
}

int main(void){

    init();

    int a,b;
    cin>>a>>b;

    ll ans = 0;
    for(int xmb=1;xmb<b;xmb++){
        ans = (ans + ((sgm[b]+1)*b%DSY)*1ll*xmb)%DSY;
    }
    cout<<ans;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;
long long a, b, ans, l, r, sum;
int main ()
{
	ios_base::sync_with_stdio (0);
	cin >> a >> b;
	for (int i = 1; i <= b - 1; i++) {
		r = ((((i * a) % mod) * b) % mod + i) % mod;
		l = ((b * i) % mod + i) % mod;
		sum = a * (l + r)/2;
		sum %= mod;
		ans += sum;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}
	}
	return true;
}
int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
ll a,b;
cin>>a>>b;
ll ans=0;
ans=b*(b-1);
ans=ans/2;
ans=ans%mod;
ll ans1=a*(a+1);
ans1=ans1%mod;
ans1=ans/2;
ans1=ans1*b;
ans1=ans1%mod;
ans1=ans1+a;
ans1=ans1%mod;
ans=ans*ans1;
ans=ans%mod;
cout<<ans<<endl;
}

#include <bits/stdc++.h>
using namespace std;
const int base = (int) 1e9 + 7;
int a, b;
int res = 0;
inline int cal(int x, int i) {
   long long result = x;
   result = result * (result+1) / 2;
   result = result*b + 1LL*i*(a/i);
   return result % base;
}
int main() {
   cin >> a >> b;
   for(int i = 1; i < b; ++i)
      res = (res + cal(a/i, i)) % base;
   cout << res << endl;
}

#include <iostream>
#include <math.h>
using namespace std;
#define modu 1e9 + 7

int main(){

	int a,b;

	cin >> a >> b;

	long long suma = 0;

	long long i = 1;

	long long k = 0;

	if(b == 1){
		cout << 0 << endl;
		return 0;
	}
	/*if(i%b == 0){
		cout << "hos"<< endl;
		i++;
	}
	else{
		k = (i/b)/(i%b);
		if(k >= 1 && k <= a){
			suma = fmod((suma + fmod(k,modu)), modu);
		}
		i++;
	}*/

	while(k <= a){
		//cout << i << endl;
		if(i%b == 0){
			i++;
			continue;
		}
		else{
			k = (i/b)/(i%b);
			//cout << "k " << k << endl;
			if(k >= 1 && k <= a){
				suma = fmod((suma + fmod(i,modu)), modu);
			}
			i++;
		}

	}

	cout <<suma << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define t int t;scanf("%d",&t);for(int v=1;v<=t;v++)
#define loop_arr(i,a,b) for(int i=a;i<b;i++)
#define loop_norm(i,a,b) for(int i=a;i<=b;i++)
#define minheap priority_queue<int,vector<int>,greater<int> >
#define maaheap priority_queue<int>
#define pb push_back
#define pop pop_back
ll BIGMOD ( ll a, ll p, ll m )
{
    ll result = 1;
    ll x = a;

    while ( p )
    {
        if ( p & 1 ) //p is odd
        {
            result = ( result * x ) % m;
        }
        x = ( x * x ) % m;
        p = p >> 1;
    }

    return result;
}

bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {

        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

int main()
{
   //fastread;
   ll a,b;
   cin>>a>>b;
   ll tmp=(b*(b-1))/2;
   tmp=tmp%mod;
   ll  exB=b%mod;
   ll sum=0;
   for(ll i=1;i<=a;i++)
   {
       ll tmp2=((i%mod)*(exB))%mod;
       sum=sum+((((tmp2%mod)*(tmp%mod))%mod)%mod + tmp%mod)%mod;
   }
   cout<<sum<<"\n";
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;

main() {

    int a, b;
    long long ans = 0;
    scanf("%d%d", &a, &b);

    for (int i = 1; i < b; i++) {
        long long mn = i, mx = a * i, cnt = (mx - mn + 1 + b) / b;
        ans += (((cnt * (cnt + 1) / 2) % md) * b) % md;
        ans = (ans + cnt * i) % md;
    }

    printf("%I64d", ans);
    return 0;
}

// Deggial tell the truth that man is but a beast
// And for the reason of that man is more than god.

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

#define VAR(v, n) __typeof(n) v = (n)
#define FOR(x, b, e) for(int x = b; x <= (e); ++x)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define FOREACH(i, c) for(VAR(i,(c).begin()); i != (c).end(); ++i)
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define CLEAR(x) (memset(x,0,sizeof(x)))
#define SZ(x) ((int)(x).size())
#define IN(x,y) ((y).find(x)!=(y).end())
#define PB push_back
#define ST first
#define ND second
#define PB push_back
#define MP make_pair
typedef long long int LL;
using namespace std;
const LL MOD = 1000000007;
LL a,b;
LL r;
int main() {
    cin >> a >> b;
    for(LL i = 1; i < b; i++) {
        LL h = a/i;
        r = (r + (((((h*(h*i+1)) / 2LL)%MOD)*b)%MOD + (i*h)%MOD)%MOD)%MOD;
    }
    cout << r << "\n";
    return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#define MOD 1000000007
using namespace std;
long long a,b,n,i,sol,sum,j;
int main()
{
    cin>>a>>b;
    sum=(a*(a+1)/2)%MOD;
    for(j=1;j<b;j++)
        sol=(sol+((a*j)%MOD)+((a*b)%MOD))%MOD;
    cout<<sol;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
#define md int(1e5)
#define modul int(1e9+7)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
int xx[4]={0,0,1,-1};
int yy[4]={1,-1,0,0};
typedef long long ll;
ll a;
int b;
int main()
{
    scanf("%I64d%d",&a,&b);
    ll res=0;
    FOR(m,1,b-1)
    {
        ll r=a*m % modul;
        ll l=m;
        ll n=(r-l+1);
        if (n%2==0)
        {
            res+= ((l+r)*((n/2)%modul)%modul)*b %modul;
            res=res%modul;
        }
        else
        {
            res+= ((l+r)/2)*(n%modul)*b % modul;
            res=res%modul;
        }
        res= (res+(n%modul)*m %modul)%modul;
    }
    cout<<res<<endl;
}

#include <bits/stdc++.h>
#include <unordered_map>
#include <initializer_list>
#include <memory>
#include <vector>
#define mp make_pair
#define pb push_back
#define lo int
#define li long long int
#define db double

#define sz(a) (lo)(a).size()
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
#define DEB(...) fprintf(stderr, __VA_ARGS__)

//=======================
//#define pi 3.14159265358979323
#define eps 1e-9
#define INF 2e9
#define MN 1000010
#define SM 2000
//=====================================================

int main()
{
#ifdef MYLOCAL
    freopen("input.txt", "r", stdin);
 //   freopen("A9.out", "w", stdout);
#else
//    freopen("matan.in", "r", stdin);
//    freopen("matan.out", "w", stdout);
#endif
    li a, b;
    cin >> a >> b;
    if(b == 1){
    	cout << 0;
    	return 0;
    }
    li Mod = 1e9 + 7;
    li ans = 0;
    for(li i = 1; i < b; i++){
    	li beg = i * b + i;
    	li val = (2 * beg + (a - 1) * b) / 2 * a;
    	val %= Mod;
    	ans = (ans + val) % Mod;
    }
    cout << ans;
};

#include <iostream>

using namespace std;

long long a, b, mod = 1e9  + 7;
void scan()
{
	cin >> a >> b;
}

void solve()
{
	long long res = 0;

	for (long long y = 1; y < b; ++y)
	{
		long long cur  = (b * y + a*y*b)*(a)/2 + a *y;
		//cout << y << " " << cur << endl;
		res += cur;
		res %= mod;
	}

	cout << res << endl;
}

void solve2()
{
	int res = 0;
	for (int i = 1; i <= 1000000; ++i)
	{
		if (i % b == 0)
			continue;
		if ((i / b)/(i % b) < 1)
			continue;
		if ((i / b)/(i % b) > a || (i/b) % (i % b) != 0)
			continue;
		res += i;
	}

	cout << res << endl;
}
int main()
{
	scan();
	solve();
	//solve2();
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
#define md int(1e5)
#define modul int(1e9+7)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
int xx[4]={0,0,1,-1};
int yy[4]={1,-1,0,0};
typedef long long ll;
ll a;
int b;
int main()
{
    scanf("%I64d%d",&a,&b);
    ll res=0;
    FOR(m,1,b-1)
    {
        ll r=a*m % modul;
        ll l=m;
        ll n=(r-l+1);
        if (n%2==0)
        {
            res+= ((l+r)*((n/2)%modul)%modul)*b;
        }
        else res+= (((l+r)/2 %modul)*n %modul)*b;
        res+= ((r-l+1)%modul)*m %modul;
    }
    cout<<res<<endl;
}

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100000 + 2;
const int MOD = (int)(1e9) + 7;

long long m;

long long power(int x, int k) {
    if (k == 1) return(x);
    long long t = power(x, k / 2);
    t = (t * t) % MOD;
    if (k % 2 == 1) t = (t * x) % MOD;
    return(t);
}

long long sum(long long n) {
    n = n % MOD;
    long long res = (n * (n + 1)) % MOD;
    res = (res * m) % MOD;
    return res;
}

int main()
{
    int a, b;
    cin >> a >> b;
    m = power(2, MOD - 2);
    long long res = 0;
    for(int i = 1; i < b; i++) {
        long long l = i, r = (long long)(a) * i;
        long long n = r - l + 1, x = n % MOD, y = (long long)(b) * i % MOD;
        res = (res + (x * i) % MOD + ((sum(r) - sum(l - 1)) * y) % MOD) % MOD;
    }
    res = (res + MOD) % MOD;
    cout << res << endl;
}

#include <bits/stdc++.h>
#define ll long long
#define maxn 100100
using namespace std;
ll ans, a, b, mod = 1e9+7, fc[maxn], num;
ll f(ll a, ll b){
    ll ans = 1;
    while(b){
        if(b&1) ans = ans*a%mod;
        a = a*a%mod;
        b >>= 1;
    }
    return ans;
}
int main(){
    fc[0] = 1;
    for(ll i=1;i<maxn;i++) fc[i] = fc[i-1]*i%mod;
    cin>>a>>b;
    ans = (a*b+b+2)*(a*b-b+1)%mod*f(2, mod-2)%mod*((b-1)*b/2%mod)%mod;
    for(ll i=1;i*i<=b&&i<b;i++){
        if(b%i == 0){
            num = (a*b+1)/(b/i)-b/(b/i);
            ans = (ans-f(b, num)*fc[(a*b+1)/(b/i)]%mod+mod)%mod*f(fc[b/(b/i)], mod-2)%mod;
        }
    }
    ans = (ans+mod)%mod;
    cout<<ans<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
const int mod =1000000007;
ll a,b;
int main()
{
    cin>>a>>b;
    ll q=b*(b-1)/2%mod,sum=0;
    for(int i=1;i<=a;i++)
    {
        sum=(sum%mod+( (q%mod)* (1+i*b)%mod)%mod)%mod;
    }
    cout<<sum%mod;
    return 0;
}
//2019-07-26 23:36:05.498

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include<cassert>
#include <set>
#include<sstream>
#include<iomanip>
#include<numeric>
#include <climits>
#include<string>
#define mp make_pair
#define pb push_back
#define EPS 1e-9
#define fi first
#define se second
#define io  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define filein freopen ("in.txt", "r", stdin);
#define all(v) ((v).begin()), ((v).end())

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MOD = 1000000007;

ll A, b;

ll Pow(int b, int e){
  if(e == 0)
    return 1;
  ll ret = Pow(b, e/2);
  ret = ret * ret % MOD;
  if(e & 1)
    ret = ret * b % MOD;
  return ret;
}

int main(){
  cin >> A >> b;
  ll ret = 0;
  ll c = Pow(2, MOD - 2);
  for(ll a = 1; a <= A; a++)
    ret = ((b * (b - 1) % MOD * c ) % MOD *  (a * b + 1) % MOD  + ret) % MOD;
  cout << ret << endl;
}

#include <bits/stdc++.h>
using namespace std;

const int MOD = 1000000007;

int main () {
	int a, b;
	cin >> a >> b;

	int ans = 0;
	for (int k = 1; k <= a; k++) {
		ans = ans + ((((((k*b+1)%MOD) * (b-1)) % MOD) * b) % MOD) / 2;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define N 100010
#define F first
#define S second

using namespace std;

long long a, b, mod = 1000000007, s = 0;

int main()
{
    //file;
    cin >> a >> b;
    if (b < 2)
    {
        cout << s;
        return 0;
    }
    for (long long i = 1; i <= a; i++)
        s = (s + ((b*i + 1)%mod)*(b*(b-1)/2)%mod) % mod;
    cout << s;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;
ll power(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b%2) res=(res*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return res;
}
ll modInv(ll x)
{
	return power(x,MOD-2);
}
/*
1) Understand the question well.
   Make sure that you can give few sample inputs and correct outputs
   by hand before moving on to implementation

2) Observe unique facts and write it down

3) Make observations and write it down

4) Implement
*/

/*

Observations
SOME THINGS CANNOT BE TYPED OUT!!!!

*/
/*

Sample Input

*/
void solve()
{
	ll a,b;
	cin>>a>>b;
	ll ans=0;
	for(ll i=1;i<=b-1;i++)
	{
		// when the modulo class ( denominator ) is i

		// Sum all the numbers j*b + j for every j : multiple of i till (a/i)*b + i

		ll n=a/i;
		ll l=i*b+i,u=n*b+i;
		ll s=((n%MOD)*((l+u)%MOD))%MOD;
		s=s*modInv(2);
		ans=(ans+s)%MOD;
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}

#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
__int64 mod=1000000007;
__int64 MultMod(__int64 a,__int64 b)
{
    a%=mod;
    b%=mod;
    if(b<0) b+=mod;
    if(a<0) a+=mod;
    __int64 res=0;
    while(b>0)
    {
       if(b&1)
       {
           res+=a;
           if(res>=mod) res-=mod;
       }
       a=a<<1;
       if(a>=mod) a-=mod;
       b=b>>1;
    }
    res%=mod;
    if(res<0) res+=mod;
    return res;
}
int main()
{
    //freopen("in.txt","r",stdin);
    __int64 a,b,ans=0;
    scanf("%I64d%I64d",&a,&b);
    for(__int64 r=1;r<=b-1;r++)
    {
        __int64 tp=MultMod(a*r,r);
        ans=(ans+tp)%mod;
        if((a*r)%2==0) tp=MultMod(((a+2)*r-1),(a*r)/2);
        else tp=MultMod(((a+2)*r-1)/2,(a*r-r+1));
        tp=(tp*b)%mod;
        ans=(ans+tp)%mod;
    }
    ans%=mod;
    if(ans<0) ans+=mod;
    printf("%I64d\n",ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll   = long long;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

ll power(ll x, ll y){
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}
const ll MOD = 1e9+7;

void solve(){
    ll a,b;cin>>a>>b;
    ll ans=0;
    for(ll i=1;i<b;i++){
        ll l = i, r = a*i;
        ll y1 = l, y2 = r;
        // y1 = b*y1+i; y2 = b*y2+i;
        ll n = (y2-y1) +1;
        if(i!=1)n = ((y2-y1)/(i))+1;
        y2 = (((b%MOD)*(y2%MOD))%MOD +i)%MOD;
        y1 = (((b%MOD)*(y1%MOD))%MOD + i)%MOD;
        if(n%2==0){
            ans += ((n/2)%MOD)*((y2+y1)%MOD);
        }else  ans += (((y2+y1)/2)%MOD)*(n%MOD);
        ans %= MOD;
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r",stdin);
        freopen("output1.txt", "w", stdout);
    #endif
    int t;
    t=1;
    // cin>>t;

    while(t--){
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>ii;
#define PB push_back
#define MP make_pair
#define IN insert
#define F first
#define S second
#define FOR(i, c, n) for(int i = c; i < (int)n ; i++)
#define FOREACH(i, v) for (__typeof(v.begin()) i = v.begin(); i != v.end(); i++)
#define BACEACH(i, v) for (__typeof(v.rbegin()) i = v.rbegin(); i != v.rend(); i++)
//--------Main---------//
const int MOD = 1000000000 + 7;
ll a,b;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>a>>b;
	ll sum=0LL;
	for(ll k = 1; k <= a; k++){
		ll tmp = ((k*b)+1)%MOD * (b*(b-1LL)/2LL)%MOD;
		sum = (sum%MOD + tmp%MOD)%MOD;
	}
	cout<<sum<<'\n';
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int M = 1e9+7;
int main()
{
	long long a,b;
	cin >> a >> b;
	cout << (((b*(a*(a+1)/2)%M+a)%M)*(b*(b-1)/2)%M)%M << endl;
}

/*
  Md. Ahsan Kabir Shohagh
  CSE, 20th Batch
  Session: 2011-12
  Shahjalal University of Science & Technology, Sylhet.
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <bitset>
#include <numeric>
#define sz 10005
#define mod 1000000007
#define pb(a) push_back(a)
#define ll long long
#define ull unsigned long long
#define fread freopen("input.txt","r",stdin)
#define fwrite freopen("output.txt","w",stdout)
#define inf (1<<25)
#define mem(abc,z) memset(abc,z,sizeof(abc))
#define PI acos(-1)
using namespace std;
int a,b,d,k;
ll ans,m;

int main()
{
    cin>>a>>b;
    ans=0ll;
    for(int i=1;i<=100*b;i++){
        d=i/b;
        m=i%b;
        if(m){
            k=d/m;
            if(k<=a && k>=1) {
               ans+=i;
               if(ans>mod) ans%=mod;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

 #include <iostream>
 #include <string>
 #include <algorithm>
 #include <cstdio>
 #include <cstring>
 #include <stdio.h>
 #include <stdlib.h>
 #include <vector>
 #include <math.h>
 #include <set>
 #include <ctime>

using namespace std;

int main()
{
    long long ans = 0;
    long long a, b;
    cin >> a >> b;
    if (b == 1)
    {
        cout << 0;
        return 0;
    }
    for (int i = 1; i < b; ++i)
    {
        long long a1 = i + b*i;
        long long an = i + (i * (a / i))*b;
        ans += (a1 + an ) / 2 * (a / i);

        ans %= 1000000007;
    }
    cout << ans;
    return 0;

}

#include <iostream>

using namespace std;

long long a, b, mod = 1e9  + 7;
void scan()
{
	cin >> a >> b;
}

void solve()
{
	long long res = 0;

	for (long long y = 1; y < b; ++y)
	{
		long long cur  = (((b * y + (a*y % mod)*b) % mod)*(a) % mod) * 500000004LL + a *y;
		//cout << y << " " << cur << endl;
		cur %= mod;
		res += cur;
		res %= cur;
	}

	cout << res << endl;
}

void solve2()
{
	int res = 0;
	for (int i = 1; i <= 1000000; ++i)
	{
		if (i % b == 0)
			continue;
		if ((i / b)/(i % b) < 1)
			continue;
		if ((i / b)/(i % b) > a || (i/b) % (i % b) != 0)
			continue;
		res += i;
	}

	cout << res << endl;
}
int main()
{
	scan();
	solve();
	//solve2();
}

#include <iostream>
using namespace std;
#define LL long long
#define M 1000000007
LL a,b;
int main() {
    cin>>a>>b;

    LL sum=0;
    for(LL i=1;i<b;++i)
    {
        LL N=(a/i);
        sum=(sum+((i*N)%M+(((b*i)%M)*(((N)*(N+1))/2)%M)%M)%M)%M;
    }
    cout<<sum<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;
ll power(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b%2) res=(res*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return res;
}
ll modInv(ll x)
{
	return power(x,MOD-2);
}
/*
1) Understand the question well.
   Make sure that you can give few sample inputs and correct outputs
   by hand before moving on to implementation

2) Observe unique facts and write it down

3) Make observations and write it down

4) Implement
*/

/*

Observations
SOME THINGS CANNOT BE TYPED OUT!!!!

*/
/*

Sample Input

*/
void solve()
{
	ll a,b;
	cin>>a>>b;
	ll ans=0;
	for(ll i=1;i<=b-1;i++)
	{
		// when the modulo class ( denominator ) is i

		// Sum all the numbers j*b + j for every j : multiple of i till (a/i)*b + i

		ll n=a/i;
		ll l=i*b+i,u=n*b+i;
		ll s=((n%MOD)*((l+u)%MOD))%MOD;
		s=(s*modInv(2))%MOD;
		ans=(ans+s)%MOD;
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define bg begin()
#define en end()
#define Y second
#define X first
typedef long long ll;
#define fi freopen("input.txt","r",stdin)
#define fo freopen("output.txt","w",stdout)
const double pi     =   acos(-1.0);
const double eps    =   1e-8;
#define print(a) cout<<(#a)<<" = "<<a<<"\n";
#define fill(a,val) memset(a ,val, sizeof(a) );
/*Solution code starts here */

const ll mod = 1000000007LL;
const ll inv = 500000004LL;

ll mult( ll a , ll b )
{
    return ( ( a%mod )*(b%mod) )%mod;
}

ll sub ( ll a, ll b)
{
     return (mod*2LL+(a%mod)-(b%mod) )%mod;
}

ll add( ll a , ll b)
{
    return ( (a%mod)+(b%mod) )%mod;
}
int main()
{
 ios_base::sync_with_stdio(0);

 ll a, b;

 cin>>a>>b;

 ll ans=0;

 for(ll c=1;c<b;c++)
   {
            ll len=c*a+1LL;

            ll lf=mult(len,inv);

            ll rt=add ( mult(2LL,c) , mult( len-1LL , b) );

            ll tp=mult(lf , rt);

            ll ad=sub(tp,c);

            ans=add(ans,ad);
   }

   cout<<ans<<endl;

 return 0;

}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
typedef long long llong;
const int MOD = 1000000007;
int main()
{
    int a,b;
    cin>>a>>b;
    llong ans=0;
    llong bb = b;
    for(int k=1;k<=a;++k)
    {
        ans = (ans + (k*bb+1)%MOD * (bb*(bb-1)/2)%MOD)%MOD;
    }
    cout<<ans<<endl;
}

#include <iostream>

using namespace std;

constexpr unsigned long long mod {1000000007};

inline void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    unsigned long long a;
    unsigned long long b;

    cin >> a >> b;

    cout << (a * (a + 1) / 2 % mod * b % mod + a) * b * (b - 1) / 2 % mod;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    long long ans = 0, mod = 1e9 + 7;
    cin >> a >> b;
    for(long long k = 1; k<b; ++k)
    {
        long long diff = b*k, first = k*b+k, n = a;
        ans+=n*(2ll*first+(n-1ll)*diff)/2ll;
        ans%=mod;
    }
    cout << ans%mod;
}

#include<bits/stdc++.h>
#define inf -1000 * 1000 * 1000
#define ll long long
#define MOD 1000 * 1000 * 1000 + 7
#define MAXN 1000100
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

	int a,b;
	cin>>a>>b;

	ll ans = (b*(b-1))/2 * ( (a*(a+1))/2 * b + a);

	cout<<ans % (MOD);

	return 0;

}

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main()
{

    long long a,b;
    cin>>a>>b;
///you have to return the sum of all the nice numbers which they are
///div(x,b)/mod(x,b)=k >>>>>> where k is a number in a range 1--->a
///let d=div(x,b) & m=mod(x,b)

    long long res=((((b-1)*b)/2)*((a*(a+1)*b)/2+a))%mod;
    cout<<res<<endl;

    return 0;

}

#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MT make_tuple
#define PB push_back
typedef long long ll;

ll a, b, sum;

int main () {
	cin >> a >> b;
	fo(i, 1, b) {
		ll t = a * (a+1) / 2 % MOD;
		t = (t * b + a * i) % MOD;
		sum += t;
	}
	printf("%lld\n", sum%MOD);
	return 0;
}

#include<vector>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<cstdlib>
#include<ctime>
#include<cstring>
#include<climits>
#include<sstream>
#include<string>
#include<set>
#include<map>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <sstream>

#define ll long long

#define FL(i,a,b) for(ll i=a;i<b;i++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define SORTF(x) sort(x.begin(),x.end(),func);
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define SET(v, val) memset(v, val, sizeof(v)) ;
#define RSORT(v) { SORT(v) ; REVERSE(v) ; }
#define ALL(v) v.begin(),v.end()
#define REVERSE(v) { reverse(ALL(v)) ; }
#define UNIQUE(v) unique((v).begin(), (v).end())
#define RUNIQUE(v) { SORT(v) ; (v).resize(UNIQUE(v) - (v).begin()) ; }
#define fill(x,n) memset(x,n,sizeof(x))
#define sl(x) scanf("%lld",&x)
#define mod 1000000007

using namespace std;

ll power (ll a, ll b)
{
    if (a == 0)
        return 0;
    ll ans = 1;
    while (b > 0)
    {
        if (b % 2)
            ans = (ans * a)%mod;
        b >>= 1;
        a = (a * a)%mod;
    }

    return ans%mod;

}
int main()
{
    ll a,b;
    cin >> a >> b;
    ll ans = 0;
    for(int i=1;i<b;i++)
    {
        ll p = i+i*b;
        ll y = p/b;
        while(y/i >= 1 && y/i <= a)
        {
            ans = (ans+p)%mod;
            p = (p + b)%mod;
            y = p/b;
        }
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main()
{
	int a,b;
	cin>>a>>b;
	if(b==1)
	{
		cout<<0<<endl;
		return 0;
	}
	if(a==1)
	{
		cout<<b+1<<endl;
		return 0;
	}
	ll ans=0;
	ll i=1;
	ll end=1ll*b*a+1;
	while(1)
	{
		ll start=1ll*(b+1)*i;
		ll last=end*i;
		ll diff=b*i;
		//cout<<diff<<endl;
		ll temp=start%b;
		if(temp==0)
			break;
		ll num=(last-start)/diff+1;
		num=(num*(last+start)%MOD)%MOD;
		num/=2;
		//cout<<num<<endl;
		ans=(ans+num)%MOD;
		//cout<<ans<<endl;
		i++;
	}
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz(v) (int)(v.size())
#define all(v) v.begin(), v.end()
#define clr(v, d) memset(v, d, sizeof(v))
#define MAX 19

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

const int mod = (int)1e9+7;

int main(){

    ll a, b;

    while(cin>>a>>b){
       cout<<((b*(b-1)/2) * ((a*(a+1)/2)*b+a)) % mod << "\n";
    }

    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <map>

using namespace std;

const long long mod=1e9+7;

int main()
{

	long long a,b;
	cin>>a>>b;

	unsigned long long res=0;
	for(long long i=0;i<a;i++){
		res+=(b*((b*b-1)%mod)/2)%mod;
		res+=i*(((b*b)%mod)*(b-1)/2)%mod;
	}

	cout<<res<<endl;

	return 0;
}

#include <iostream>

using namespace std;

const int M = 1e9 + 7;

int main()
{
    int a, b;
    cin >> a >> b;

    long long b_prime = (b * (b - 1) / 2) % M, ans = 0;

    for (int k = 1; k <= a; ++k)
    {
        ans += (k * b % M + 1) * b_prime % M;
        ans %= M;
        if (ans < 0)
            ans += M;
    }

    cout << ans;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define mx 1005
#define inf 2e9
#define Nitro ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

ll gcdExtended(ll a, ll b, ll *x, ll *y);

// Function to find modulo inverse of b. It returns
// -1 when inverse doesn't
ll modInverse(ll b, ll m)
{
    ll x, y; // used in extended GCD algorithm
    ll g = gcdExtended(b, m, &x, &y);

    // Return -1 if b and m are not co-prime
    if (g != 1)
        return -1;

    // m is added to handle negative x
    return (x%m + m) % m;
}

// Function to compute a/b under modlo m
ll modDivide(ll a, ll b, ll m)
{
    a = a % m;
    ll inv = modInverse(b, m);
    if(inv == -1){
        cout<<"OOPS";
    }
    return (inv * a) % m;
}

// C function for extended Euclidean Algorithm (used to
// find modular inverse.
ll gcdExtended(ll a, ll b, ll *x, ll *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    ll x1, y1; // To store results of recursive call
    ll gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    Nitro;
    ll a,b;
    cin>>a>>b;
    int r = ((b%mod)*((b-1)%mod))/2;
    r = r %mod ;
    r = (r%mod*a%mod)%mod;
    int gh = ((b%mod)*((a+1)%mod))%mod ;

    int k = modDivide(gh, 2 ,mod) ;

    int g = (1 + k)%mod;
    cout<<((g%mod)*(r%mod))%mod;

    //modDivide(a,b,mod)

    //? ? ?
    //++-

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define fl(i,a,b) for(int i=a;i<b;i++)
#define rfl(i,a,b) for(int i=a;i>b;i--)
#define cases() ll t;cin>>t;while(t--)
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mx 200000+10
const ll INF=1e18;
const ll MOD =1e9+7;
int main()
{
	ll a,b;
	cin>>a>>b;
	ll x=((a*(a+1)/2)*b)+a;
	ll y=(b*(b-1))/2;
	cout<<(x%MOD * y%MOD)%MOD;
	return 0;
}

#include <iostream>
#define M 1000000007
using namespace std;
int main()
{
	long long int a,b;
	cin>>a>>b;
	long long int fir =( ((a%M)*(b%M)*((b-1)%M))/2)%M;
	long long int sec = ((((a+1)%M) *(b%M))/2)%M;
	long long int sum = (fir%M)*((sec+1)%M);
	cout<<sum<<"\n";
}

#include<vector>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<cstdlib>
#include<ctime>
#include<cstring>
#include<climits>
#include<sstream>
#include<string>
#include<set>
#include<map>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <sstream>

#define ll long long

#define FL(i,a,b) for(ll i=a;i<b;i++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define SORTF(x) sort(x.begin(),x.end(),func);
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define SET(v, val) memset(v, val, sizeof(v)) ;
#define RSORT(v) { SORT(v) ; REVERSE(v) ; }
#define ALL(v) v.begin(),v.end()
#define REVERSE(v) { reverse(ALL(v)) ; }
#define UNIQUE(v) unique((v).begin(), (v).end())
#define RUNIQUE(v) { SORT(v) ; (v).resize(UNIQUE(v) - (v).begin()) ; }
#define fill(x,n) memset(x,n,sizeof(x))
#define sl(x) scanf("%lld",&x)
#define mod 1000000007

using namespace std;

ll power (ll a, ll b)
{
    if (a == 0)
        return 0;
    ll ans = 1;
    while (b > 0)
    {
        if (b % 2)
            ans = (ans * a);
        b >>= 1;
        a = (a * a);
    }

    return ans;

}
int main()
{
    ll a,b;
    cin >> a >> b;
    ll ans = 0;
    for(int i=1;i<b;i++)
    {
        ll p = i+b;
        while((p/b)/i >= 1 && (p/b)/i <= a)
        {
            ans = (ans+p)%mod;
            p+=b;
        }
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ull unsigned long long int
#define rep(i,a,b) for (ll i = a; i <= b; i++)
#define ren(i,a,b) for(ll i=b;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define DB pop_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define V(a) vector<a>
#define MOD 1000000007
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
////////////////////

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*int t;
    cin>>t;
    while(t--)*/
    ll a,b,ans=0;
    cin>>a>>b;
    rep(i,1,b-1)
    {
        ans+=(((a*i/2)%MOD)*((2*b+2+((a-1)*b))%MOD))%MOD;
    }
    cout<<ans%MOD<<'\n';
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100000 + 2;
const int MOD = (int)(1e9) + 7;

long long m;

long long power(int x, int k) {
    if (k == 1) return(x);
    long long t = power(x, k / 2);
    t = (t * t) % MOD;
    if (k % 2 == 1) t = (t * x) % MOD;
    return(t);
}

long long sum(long long n) {
    n = n % MOD;
    long long res = (n * (n + 1)) % MOD;
    res = (res * m) % MOD;
    return res;
}

int main()
{
    int a, b;
    cin >> a >> b;
    m = power(2, MOD - 2);
    long long res = 0;
    for(int i = 1; i < b; i++) {
        long long l = i, r = (long long)(a) * i;
        long long n = r - l + 1;
        res = (res + (n * i) % MOD + ((sum(r) - sum(l - 1)) * b) % MOD) % MOD;
    }
    res = (res + MOD) % MOD;
    cout << res << endl;
}

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){

    //freopen("in.txt","r",stdin);

    unsigned long long a,b;
    cin>>a>>b;
    int sum=0;

    //cout<<a*a<<endl;

    for(unsigned long long k=1;k<=a;k++){
	  sum= ( sum + (k*b% 1000000007+1) % 1000000007 * b % 1000000007  * (b-1)/2 % 1000000007 )%1000000007;
	  //cout<<sum<<endl;
	}
    cout<<sum<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

long long a, b;
const long long mod = 1e9 + 7;

int main(){
	cin >> a >> b;
	cout << (((b*(b-1)%mod)/2)*(a+ b*((a*((a+1)/2))%mod)%mod)%mod)%mod << endl;
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iterator>
#include <ctime>

typedef unsigned int uint32;
typedef signed long long int64;
typedef unsigned long long uint64;

using namespace std;

#define ALL(a) a.begin(), a.end()
#define FOR(a) for (int i = 0; i < (a); ++i)
#define D(a) #a << ": " << a << "\n"

int main()
{
    int64 a, b;
    cin >> a >> b;

#define MOD 1000000007
    int64 res = 0;
    int64 res2 = 0;
    for (int64 c = 1; c < b; ++c)
    {
        if (c > a)
            break;

        res += (a/c) * c;
        res %= MOD;

        int64 tmp = (a/c) * ((a/c)+1LL) / 2LL;
        tmp %= MOD;
        tmp *= b;
        tmp %= MOD;
        tmp *= c;
        tmp %= MOD;
        res += tmp;
        res %= MOD;

//         int64 num = c;
//         while (num <= a)
//         {
//             res2 += num * b + c;
//
//             res2 %= MOD;
//             num += c;
//          }
    }

    //assert(res == res2);
    cout << res << endl;
    return 0;
}

#include <iostream>

using namespace std;

int main() {
	long a, b;
	cin >> a >> b;
	long sum = 0;
	for (long i = 1; i <= a; i++) {
		for (long j = 1; j < b; j++) {
			//cout << i * j * b + b - 1 << endl;
			sum = (sum + i * j * b + b - 1) % 1000000007;
		}
	}
	cout << sum << endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()

const int inf = (1ll << 31) - 1;

#define MAXN (int) (1e7)
using namespace std;
const int mod = (int) 1e9 + 7;

int main () {
    #ifdef LOCAL
    freopen ("a.in", "r", stdin);
    freopen ("a.out", "w", stdout);
    #endif

    int a, b;
    cin >> a >> b;
    ll ans = 0, d  = (a * 1ll * ( a + 1)/ 2) % mod;
    d = (d * 1ll * a) % mod;
    d = (d + a) % mod;
    for(int i = 1; i < b; i++){
        ans = (ans + d * 1ll * i) % mod;
    }
    cout << ans << endl;

    #ifdef LOCAL
    cerr << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int a, b, ans, t;
    cin >> a >> b;
    ans = a * (a + 1) / 2;
    ans *= b * (b - 1) / 2;
    ans %= MOD;
    ans *= b;
    ans %= MOD;
    t = b * (b - 1) / 2;
    t *= a;
    t %= MOD;
    ans += t;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> pii;

const int mod = 1000000007;

int main() {
	//freopen ("in.txt", "r", stdin);
	//freopen ("out.txt", "w", stdout);

	ll a, b;

	while (scanf("%I64d %I64d", &a, &b) == 2) {

        ll ans = 0;

        ll banyak = (b - 1) * b / 2 % mod;

        for (int i = 1; i <= a; i++) {
            ans += (i * b + 1) * banyak;
            ans %= mod;
        }

        printf("%I64d\n", ans);
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define N 100005
#define mod 1000000007

int main()
{
    ll a,b,i,n,ans=0,first,last,t;

    cin>>a>>b;
    ll one=1;

    for(i=1;i<b;i++)
    {
        first=b*i+i;
        last=first+(b*i)*(a-1);
        t=first+last;
        n=a;
        if((n&one) == 0)
        {
           // cout<<"hi"<<endl;
            ans+=( (n>>one)%mod * t%mod);
            ans%=mod;
        }
        else
        {
            ans+=((t>>one)%mod*(n%mod));
            ans%=mod;
        }

    }

    cout<<ans<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
long long a,b,ans=0;
int main()
{
    scanf("%I64d%I64d",&a,&b);
    for(long long k=1;k<=a;k++)
    {
        ans=(ans+(k*b+(b-1)*b/2)*(b-1))%MOD;
    }
    printf("%I64d\n",ans);
    return 0;
}