#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back
#define sz(a) (ll) a.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, a, b) for(ll i=(ll)(a); i<(ll)(b); i++)
#define rrep(i, a, b) for(ll i=(ll)(a); i>=(ll)(b); i--)
#define vl vector<ll>
#define vpll vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define pll pair<ll, ll>
const ll md=1e9+7;
#define S ll
S e(){ return -1; }
S op(S a, S b){
  if(a==-1) return b;
  if(b==-1) return a;
  return min(a, b);
}
struct segtree{
  int n;
  vector<S> d;
  segtree(vector<S>& v){
    n=v.size();
    d.assign(4*n, e());
    build(v);
  }
  void build(vector<S>& v, int p=1, int tl=0, int tr=-1){
    if(tr==-1) tr=n-1;
    if(tl==tr){
      d[p]=v[tl];
      return;
    }
    int mid=(tl+tr)/2;
    build(v, 2*p, tl, mid);
    build(v, 2*p+1, mid+1, tr);
    d[p]=op(d[2*p], d[2*p+1]);
  }
  void apply(int w, S nw, int p=1, int tl=0, int tr=-1){
    if(tr==-1) tr=n-1;
    if(tl==tr){
      d[p]=nw;
      return;
    }
    int mid=(tl+tr)/2;
    if(w<=mid) apply(w, nw, 2*p, tl, mid);
    else apply(w, nw, 2*p+1, mid+1, tr);
    d[p]=op(d[2*p], d[2*p+1]);
  }
  S find(int l, int r, int p=1, int tl=0, int tr=-1){
    if(tr==-1) tr=n-1;
    if(l>r) return e();
    if(l==tl && r==tr) return d[p];
    int mid=(tl+tr)/2;
    return op(find(l, min(mid, r), 2*p, tl, mid), find(max(mid+1, l), r, 2*p+1, mid+1, tr));
  }
};
ll cnt(ll a, ll b){
  ll ret=((((a+1)*(a))/2 % md) * (((b+1)*(b))/2 % md)) % md;
  return ret;
}
void f() {
  ll n; cin >> n; ll cntw=0;
  vl h(n), w(n); 
  for(auto& u : h) cin >> u;
  for(auto& u : w){ cin >> u; cntw+=u; }
  cout << cnt(h[0], cntw);
}
int main() {
  int tc=1;
  while (tc--) f();
}
| # | 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... |