import java.io.*; import java.util.*; import java.math.BigInteger; public class Solution { public static void main(String[] args) { InputReader in = new InputReader(System.in); OutputWriter ou = new OutputWriter(System.out); int n = in.ni(); long[] p = in.nla(n); long[] x = in.nla(n); int m = in.ni(); long[] y = in.nla(m); long[] r = in.nla(m); long result = maximumPeople(p, x, y, r); ou.ptn(result); } static long maximumPeople(long[] p, long[] x, long[] y, long[] r) { // Return the maximum number of people that will be in a sunny town after removing exactly one cloud. long h = p.length; long c = r.length; long res = Integer.MIN_VALUE; HashMap cd = new HashMap<>(); HashMap pp = new HashMap<>(); for (int i = 0; i < h; i++) { pp.put(x[i], p[i]); } long sunn=Long.MIN_VALUE; HashMap h1ca=new HashMap<>(); for (int i = 0; i < c; i++) { long pos = y[i]; long ll = Math.max(1, pos - r[i]); long ul = pos + r[i]; long cc = 0; for (long j = ll; j <= ul; j++) { if(pp.containsKey(j)){ cc+=pp.get(j); h1ca.put(j,true); } } if(cc>sunn){ sunn=cc; } } long sol=0; for (Map.Entryentry : pp.entrySet()) { Long xx= entry.getKey(); Long pop = entry.getValue(); if(h1ca.get(xx)==null){ sol+=pop; } } return sol+sunn; } static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; public InputReader(InputStream st) { this.stream = st; } public int read() { if (snumChars == -1) { throw new InputMismatchException(); } if (curChar >= snumChars) { curChar = 0; try { snumChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (snumChars <= 0) { return -1; } } return buf[curChar++]; } public int ni() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public long nl() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } long res = 0; do { res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public double nd() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } double res = 0; while (!isSpaceChar(c) && c != '.') { if (c == 'e' || c == 'E') { return res * Math.pow(10, ni()); } if (c < '0' || c > '9') { throw new InputMismatchException(); } res *= 10; res += c - '0'; c = read(); } if (c == '.') { c = read(); double m = 1; while (!isSpaceChar(c)) { if (c == 'e' || c == 'E') { return res * Math.pow(10, ni()); } if (c < '0' || c > '9') { throw new InputMismatchException(); } m /= 10; res += (c - '0') * m; c = read(); } } return res * sgn; } public String ns() { //single string int c = read(); while (isSpaceChar(c)) { c = read(); } StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public String nli() { //one entire sentence int c = read(); while (isSpaceChar(c)) { c = read(); } StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndOfLine(c)); return res.toString(); } public boolean nb() { return Boolean.parseBoolean(ns()); } public int[] nia(int n) { int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = ni(); } return a; } public double[] nda(int n) { double a[] = new double[n]; for (int i = 0; i < n; i++) { a[i] = nd(); } return a; } public long[] nla(int n) { long a[] = new long[n]; for (int i = 0; i < n; i++) { a[i] = nl(); } return a; } /*public boolean[] nba(int n) { boolean a[] = new boolean[n]; for (int i = 0; i < n; i++) { a[i] = nb(); } return a; } public String[] nsa(int n) { String a[] = new String[n]; for (int i = 0; i < n; i++) { a[i] = ns(); } return a; } public String[] nlia(int n) { String a[] = new String[n]; for (int i = 0; i < n; i++) { a[i] = nli(); } return a; } public int[][] nim(int m,int n){ int a[][]=new int[n][m]; for(int i=0;i