#include using namespace std; int main() { constexpr int64_t mod = 1000000007; int n; cin >> n; vector a(n + 1), b(n + 1), s(n + 2); for (int i = 0; i <= n; i++) cin >> a.at(i); for (int i = 0; i <= n; i++) cin >> b.at(i); for (int i = 0; i <= n; i++) { s.at(i + 1) = (s.at(i) + a.at(i)) % mod; } int64_t ans = 0; for (int i = 0; i <= n; i++) { ans += s.at(i + 1) * b.at(n - i); ans %= mod; } cout << ans << endl; }