import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long maximumPeople(long[] ps, long[] xs, long[] ys, long[] rs) { long[] cover = new long[xs.length]; for (int i = 0; i < ys.length; i++) { long start = Arrays.binarySearch(xs, ys[i]-rs[i]); if (start < 0) start = -(start + 1); long end = Arrays.binarySearch(xs, ys[i]+rs[i]); if (end < 0) end = -(end + 1); if (end > xs.length) end = xs.length - 1; for (int j = (int)start; j <= end; j++) { if (cover[j] > 0) { cover[j] = -1; } else { cover[j] = i+1; } } } long sunny = 0; long[] cloud = new long[ys.length]; for (int i = 0; i < xs.length; i++) { if (cover[i] == 0) { sunny += ps[i]; continue; } else if (cover[i] == -1) continue; int c = (int)cover[i] - 1; cloud[c] = cloud[c] + ps[i]; } long biggest = 0; for (int i = 0; i < cloud.length; i++) { if (biggest < cloud[i]) { biggest = cloud[i]; } } sunny += biggest; return sunny; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[] p = new long[n]; for(int p_i = 0; p_i < n; p_i++){ p[p_i] = in.nextLong(); } long[] x = new long[n]; for(int x_i = 0; x_i < n; x_i++){ x[x_i] = in.nextLong(); } int m = in.nextInt(); long[] y = new long[m]; for(int y_i = 0; y_i < m; y_i++){ y[y_i] = in.nextLong(); } long[] r = new long[m]; for(int r_i = 0; r_i < m; r_i++){ r[r_i] = in.nextLong(); } long result = maximumPeople(p, x, y, r); System.out.println(result); in.close(); } }