#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

const int nmax = 2e5 + 5;
const int mmax = 1e5 + 5;
const int lmax = nmax + 2 * mmax + 5;

int p[nmax + 1], x[nmax + 1];
int y[mmax + 1], r[mmax + 1];

long long nori[lmax + 1];
long long s[lmax + 1], v[lmax + 1];

map< int, int > mp;

int main() {
    int n, m;
    cin >> n;

    for (int i = 1; i <= n; ++ i)
        cin >> p[ i ];
    for (int i = 1; i <= n; ++ i) {
        cin >> x[ i ];
        mp[ x[ i ] ] = 1;
    }
    cin >> m;

    for (int i = 1; i <= m; ++ i)
        cin >> y[ i ];
    for (int i = 1; i <= m; ++ i) {
        cin >> r[ i ];
        mp[y[ i ] - r[ i ]] = 1;
        mp[y[ i ] + r[ i ]] = 1;
    }

    int ind = 0;
    for (auto &i : mp)
        i.second = ++ ind;

    for (int i = 1; i <= m; ++ i) {
        ++ nori[ mp[y[ i ] - r[ i ] ] ];
        -- nori[mp[y[ i ] + r[ i ] ] + 1];
    }
    for (int i = 1; i <= n; ++ i) {
        v[ mp[ x[ i ] ] ] += p[ i ];
    }

    int l = n + 2 * m + 1;
    long long zero = 0;

    for (int i = 1; i <= l; ++ i) {
        nori[ i ] += nori[i - 1];
        s[ i ] = s[i - 1];

        if (nori[ i ] == 1) {
            s[ i ] += v[ i ];
        } else if (nori[ i ] == 0) {
            zero += v[ i ];
        }
    }

    long long ans = zero;
    for (int i = 1; i <= m; ++ i) {
        ans = max(ans, zero + s[mp[y[ i ] + r[ i ]]] - s[mp[y[ i ] - r[ i ]] - 1]);
    }
    cout << ans << "\n";
    return 0;
}