#include #include #include #include #include #include using namespace std; using ll = long long; #define rep(i, j, n) for (int i = j; i < (int)n; ++i) #define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i) constexpr ll MOD = 1000000007; constexpr int INF = 0x3f3f3f3f; constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL; int main() { int n; cin >> n; vector a(n + 1), b(n + 1); rep(i, 0, n + 1) cin >> a[i]; rep(i, 0, n + 1) cin >> b[i]; rep(i, 0, n)(b[i + 1] += b[i]) %= MOD; ll ans = 0; rep(i, 0, n + 1)(ans += a[i] * b[n - i] % MOD) %= MOD; cout << ans << endl; return 0; }