#include using namespace std; #define FOR(i,n,m) for(int i=(n);i<(m);i++) #define REP(i,n) FOR(i,0,n) #define all(vec) vec.begin(),vec.end() using ll=long long; using vi=vector; using vvi=vector; using vl=vector; using vvl=vector; using P=pair; using PP=pair; #define pb push_back #define fi first #define se second const int MOD=1e9+7; const int INF=1e9; const ll LINF=1LL<<60; templatebool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;} template struct ModInt{ int x; ModInt():x(0){} ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){} ModInt &operator+=(const ModInt &p){ if((x+=p.x)>=mod)x-=mod; return *this; } ModInt &operator-=(const ModInt &p){ if((x+=mod-p.x)>=mod)x-=mod; return *this; } ModInt &operator*=(const ModInt &p){ x=(int)(1LL*x*p.x%mod); return *this; } ModInt &operator/=(const ModInt &p){ *this*=p.inverse(); return *this; } ModInt operator-()const{return ModInt(-x);} ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;} ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;} ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;} ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;} bool operator==(const ModInt &p)const{return x==p.x;} bool operator!=(const ModInt &p)const{return x!=p.x;} ModInt inverse()const{ int a=x,b=mod,u=1,v=0,t; while(b>0){ t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); } return ModInt(u); } friend ostream &operator<<(ostream &os,const ModInt &p){ return os<>(istream &is,ModInt &a){ long long x; is>>x; a=ModInt(x); return (is); } }; const int mod=1e9+7; using mint=ModInt; int main(){ int n; cin>>n; n++; vector a(n); REP(i,n){ cin>>a[i]; } vector b(n); REP(i,n){ cin>>b[i]; } mint ans=0; mint sum=0; REP(i,n){ sum+=a[i]; } REP(i,n){ ans+=sum*b[i]; sum-=a.back(); a.pop_back(); } cout<