import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.ArrayList; import java.util.List; public class Solution { static long maximumPeople(long[] p, long[] x, long[] y, long[] r) { if (y.length == 1) { int xx = 0; for (long p1 : p) { xx += p1; } return xx; } List list = new ArrayList<>(); for (int i = 0; i < x.length; i++) { City c = new City(0, p[i]); for (int j = 0; j < y.length; j++) { if ((x[i] - (y[j] + r[j])) <= 0 | (x[i] - (y[j] - r[j])) >= 0 | (x[i] - (y[j])) == 0) { c.increaseClouds(); } } list.add(c); } City res = null; for (int i = 0; i < list.size(); i++) { long populationFlag = 0; if (list.get(i).clouds == 1 & list.get(i).population > populationFlag) { res = list.get(i); } } return res.population; } 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(); } static class City { public long clouds = 0; public long population = 0; public City(long clouds, long population) { this.clouds = clouds; this.population = population; } void increaseClouds() { this.clouds++; } } }