#include #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; class mint{ static const int MOD=1e9+7; int x; public: mint():x(0){} mint(long long y){ x=y%MOD; if(x<0) x+=MOD; } mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; } mint& operator-=(const mint& m){ x-=m.x; if(x< 0) x+=MOD; return *this; } mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; } mint& operator/=(const mint& m){ return *this*=inverse(m); } mint operator+(const mint& m)const{ return mint(*this)+=m; } mint operator-(const mint& m)const{ return mint(*this)-=m; } mint operator*(const mint& m)const{ return mint(*this)*=m; } mint operator/(const mint& m)const{ return mint(*this)/=m; } mint operator-()const{ return mint(-x); } friend mint inverse(const mint& m){ int a=m.x,b=MOD,u=1,v=0; while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); } return u; } friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; } friend ostream& operator<<(ostream& os,const mint& m){ return os<0;k>>=1,m*=m) if(k&1) res*=m; return res; } int main(){ int n; scanf("%d",&n); vector a(n+1),b(n+1); rep(i,n+1) scanf("%d",&a[i]); rep(i,n+1) scanf("%d",&b[i]); vector bsum(n+2); rep(i,n+1) bsum[i+1]=bsum[i]+b[i]; mint ans=0; rep(i,n+1) ans+=a[i]*bsum[n-i+1]; printf("%d\n",ans.to_int()); return 0; }