#include using namespace std; int main() { int n; cin >> n; long long a[n+1], b[n+1]; for (int i = 0; i <= n; i++) cin >> a[i]; for (int i = 0; i <= n; i++) cin >> b[i]; long long s = 0, ans = 0; const long long M = 1000000007; for (int i = 0; i <= n; i++) { s += b[i]; if (s >= M) s -= M; ans += a[n-i] * s % M; if (ans >= M) ans -= M; } cout << ans << endl; }