import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static class City { public long population; public int clouds; public City(long p) { population = p; clouds = 0; } } 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. HashMap xIndex = new HashMap(); for(int i = 0; i < x.length; i++) xIndex.put(x[i], new City(p[i])); for(int i = 0; i < y.length; i++) { for(long j = y[i] - r[i]; j <= y[i] + r[i]; j++) { if(xIndex.containsKey(j)) xIndex.get(j).clouds++; } } long maxPop = 0; for(int i = 0; i < x.length; i++) if(xIndex.get(x[i]).clouds == 0) maxPop+= xIndex.get(x[i]).population; long max = 0; for(int i = 0; i < y.length; i++) { long temp = 0; for(long j = y[i] - r[i]; j <= y[i] + r[i]; j++) { if(xIndex.containsKey(j) && xIndex.get(j).clouds == 1) temp+= xIndex.get(j).population; } if(temp > max) max = temp; } maxPop+= max; return maxPop; } 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(); } }