#include<bits/stdc++.h>
#include<bits/extc++.h>
#define fi first
#define se second
#define int long long
using namespace std;
//using namespace __gnu_pbds;
using db=double;
using ll=int64_t;
using sll=__int128;
using lb=long double;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<int mod, int RT>struct mint{
int v;
static constexpr mint rt(){ return RT; }
explicit operator int() const { return v; }
mint():v(0){}
mint(int _v):v((int)(_v%mod)){ v+=(v<0)*mod; }
mint& operator+=(mint o){
if((v+=o.v)>=mod)v-=mod;
return *this;
}
mint& operator-=(mint o){
if((v-=o.v)<0)v+=mod;
return *this;
}
mint& operator*=(mint o){
v=(int)((int)(v*o.v%mod));
return *this;
}
mint& operator/=(mint o){
*this*=inv(o);
return *this;
}
friend mint mpow(mint a, int x){
if(x==0)return 1;
mint t=mpow(a,x>>1);
if(x%2==0)return t*t;
return t*t*a;
}
friend mint inv(mint a){
return mpow(a,mod-2);
}
friend mint operator+(mint a, mint b){ return a+=b; }
friend mint operator-(mint a, mint b){ return a-=b; }
friend mint operator*(mint a, mint b){ return a*=b; }
friend mint operator/(mint a, mint b){ return a/=b; }
mint operator-() const { return mint(-v); }
mint& operator++() { return *this+=1; }
mint& operator--() { return *this-=1; }
bool operator==(const mint& o) const { return v==o.v; }
bool operator!=(const mint& o) const { return v!=o.v; }
}; using mi=mint<(int)1e9+7,5>;
int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(0));
int n; cin>>n; vector<int>h(n+1); vector<int>w(n+1); mi toth=0; mi totw=0;
for(int i=1; i<=n; i++){ cin>>h[i]; toth+=h[i]; }
for(int i=1; i<=n; i++){ cin>>w[i]; totw+=w[i]; }
mi ans=totw*(totw+1)*toth*(toth+1)/4; cout<<(int)ans<<'\n';
}
/*
Overhead the albatross hangs motionless upon the air
And deep beneath the rolling waves in labyrinths of coral caves
The echo of a distant time comes willowing across the sand
And everything is green and submarine
And no one showed us to the land
And no one knows the wheres or whys
But something stirs and something tries
And starts to climb towards the light
*/
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |