import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long maximumPeople(ArrayList p, ArrayList x, ArrayList y, ArrayList r, int n, int m, long sum) { TreeSet ts=new TreeSet(); for(int i=0;i=x.get(j)&&range-loc<=x.get(j)) ts.add(p.get(j)); } } ts.remove((long)ts.last()); if(ts==null) return sum; else { Iterator i=ts.iterator(); while(i.hasNext()) { sum-=i.next(); } return sum; } } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long temp,sum=0; ArrayList p = new ArrayList(); for(int p_i = 0; p_i < n; p_i++){ temp=in.nextLong(); p.add(temp); sum+=temp; } ArrayList x=new ArrayList(); for(int x_i = 0; x_i < n; x_i++){ x.add(in.nextLong()); } int m = in.nextInt(); ArrayList y=new ArrayList(); for(int y_i = 0; y_i < m; y_i++){ y.add(in.nextLong()); } ArrayList r =new ArrayList(); for(int r_i = 0; r_i < m; r_i++){ r.add(in.nextLong()); } long result = maximumPeople(p, x, y, r, n, m, sum); System.out.println(result); in.close(); } }