#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)(x).size()) #define pb push_back using ll = long long; using namespace std; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N; N++; vector A(N),B(N,0); rep(i,N) cin >> A[i]; rep(i,N) cin >> B[i]; ll ans = 0; ll s=accumulate(all(B),0LL)%mod; rep(i,N){ ans+=A[i]*s; ans%=mod; s+=(mod-B[N-1-i]); s%=mod; } cout << ans%mod << endl; return 0; }