#include<bits/stdc++.h>
using namespace std;
#define pi acos(0.0)
#define ll long long
#define f first
#define s second
#define gap ' '
#define pb push_back
#define mod 1000000007
int main()
{
    ll n,m;
    cin>>n>>m;
    ll x[n+5],y[m+5];
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>y[i];
    }
    sort(x,x+n);
    sort(y,y+m);
    ll xx=0;
    ll yy=0;
    for(int i=0;i<n;i++)
    {
        xx+=(i-(n-1))*x[i]+i*x[i];
        //cout<<xx<<endl;
    }

    for(int i=0;i<m;i++)
    {
        yy+=(i-(m-1))*y[i]+i*y[i];
    }

    ll ans=((xx%mod)*(yy%mod))%mod;
    cout<<ans;

}

#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;
const long INF = 2000000000;

int main() {
  long n;
  cin >> n;
  long a[n];
  for(int i = 0; i < n; i++)
    cin >> a[i];
  
  long sum[n];
  sum[n-1] = a[n-1];
  for(int i = n-2; i >= 0; i--)
    sum[i] = sum[i+1] + a[i];
  
  long ans = 0;
  for(int i = 0; i < n-1; i++)
    ans += (sum[i+1] % mod * a[i]) % mod;
  
  cout << ans % mod << endl;
}