#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; #include using mint = atcoder::modint1000000007; int main() { int n; cin >> n; vector a(n + 1), b(n + 1); rep(i, n + 1) cin >> a[i]; rep(i, n + 1) cin >> b[i]; mint ans = 0, sum = accumulate(a.begin(), a.end(), mint(0)); rep(i, n + 1) { ans += sum * b[i]; sum -= a[n - i]; } cout << ans.val() << endl; return 0; }