代码如下:

#include <iostream>
#include <cstdio>
using namespace std;
typedef long long LL;
const int mod = 1e9 + 7;
const int maxn = 3e5 + 5;
LL a[maxn], w[maxn], f[maxn], g[maxn], ans = 0;
int main()
{
    int n;
    cin >> n;
    g[0] = f[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        f[i] = a[i] + f[i - 1];
        g[i] = (f[i] + g[i - 1]) % mod;
    }
    for(int i = 1; i <= n; i++)
        cin >> w[i];
    for(int i = 1; i <= n; i++)
        ans = (ans + (g[n] - g[n - i] - g[i - 1]) * w[i] % mod) % mod;
    cout << (ans + mod) % mod << endl;
    return 0;
}