#include using namespace std; const int M = int(1e9 + 7); signed main() { ios::sync_with_stdio(false); int N; cin >> N; vector A(N + 1); for (int i = 0; i < N + 1; ++i) cin >> A[i]; vector B(N + 1); for (int i = 0; i < N + 1; ++i) cin >> B[i]; vector bsum(N + 2); partial_sum(B.begin(), B.end(), bsum.begin() + 1, [](int s, int x) { return (s + x) % M; }); int ans = 0; for (int i = 0; i < N + 1; ++i) (ans += 1LL * A[i] * bsum[N + 1 - i] % M) %= M; if (ans < 0) ans += M; cout << ans << endl; return 0; }