#include using ll = long long; constexpr ll MOD = 1000000007; int main() { int N; std::cin >> N; std::vector a(N + 1), b(N + 1); for (int i = 0; i <= N; i++) { std::cin >> a[i]; } for (int i = 0; i <= N; i++) { std::cin >> b[i], (b[i] += (i == 0 ? 0 : b[i - 1])) %= MOD; } ll ans = 0; for (int i = 0; i <= N; i++) { (ans += a[i] * b[N - i] % MOD) %= MOD; } std::cout << ans << std::endl; return 0; }