#include using namespace std; using ll = long long; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b void vprint(T &V){ for(auto v : V){ cout << v << " "; } cout << endl; } struct AccSum{ vector Ac; ll L; AccSum(vector &A){ L = A.size(); Ac.resize(L+1); FOR(i, 0, L){ Ac[i+1] = Ac[i] + A[i]; } } // sum of [a, b] ll sum(ll a, ll b){ if(a<0){ p("error"); return -1; } if(b>L-1){ p("error"); return -1; } ll ans = Ac[b+1] - Ac[a]; if(ans < 0){ p("error"); } return ans % mod; } }; int main(){ cin.tie(0); ios::sync_with_stdio(false); // input ll N; cin >> N; vector A(N+1); FOR(i, 0, N+1){ cin >> A.at(i); } vector B(N+1); FOR(i, 0, N+1){ cin >> B.at(i); } auto Acc = AccSum(B); ll sum = 0; FOR(i, 0, N+1){ sum += (A[i] * (Acc.sum(0, N-i) % mod)) % mod; sum %= mod; } p(sum); return 0; }