import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.TreeMap; public class CloudyDay { static TreeMap town = new TreeMap(new Comp()); static HashMap cloud = new HashMap(); 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++){ town.put(p[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(); for(long i = (y[r_i]-r[r_i]);i<=(y[r_i]+r[r_i]);i++){ if(cloud.containsKey(i)){ cloud.put(i,cloud.get(i)+1); }else{ cloud.put(i,Long.valueOf(1)); } } } long result = maximumPeople(); System.out.println(result); in.close(); } private static long maximumPeople() { long sum=0; for(Map.Entry entry : town.entrySet()){ long p = entry.getKey(); long c = entry.getValue(); if(!cloud.containsKey(c)){ sum+=p; }else if(cloud.containsKey(c)){ if(cloud.get(c)==1){ sum+=p; break; } } } return sum; } } class Comp implements Comparator{ @Override public int compare(Long o1, Long o2) { return Long.compare(o2,o1); } }