import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static HashMap towns;//loc, pop static HashMap clouds;//loc, num clouds static long maximumPeople(long[] locC, long[] ranges) { long total = 0; Set ks = towns.keySet(); Iterator it = ks.iterator(); while(it.hasNext()){ long next = (long)it.next(); if(clouds.containsKey(next)) continue; else{ total += towns.get(next); } } long max = 0; for(int i = 0; i < locC.length; ++i){ long value = total; for(long j = locC[i] - ranges[i]; j <= locC[i] + ranges[i]; ++j){ if(towns.containsKey(j) && clouds.get(j) == 1) value += towns.get(j); } if(value > max) max = value; } return max; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[] p = new long[n]; towns = new HashMap(); clouds = new HashMap(); for(int p_i = 0; p_i < n; p_i++){//population p[p_i] = in.nextLong(); } for(int x_i = 0; x_i < n; x_i++){//loc town towns.put(in.nextLong(), p[x_i]); } int m = in.nextInt(); long[] y = new long[m]; for(int y_i = 0; y_i < m; y_i++){//loc cloud y[y_i] = in.nextLong(); } long[] ranges = new long[m]; for(int r_i = 0; r_i < m; r_i++){//range cloud ranges[r_i] = in.nextLong(); for(long i = y[r_i] - ranges[r_i]; i <= y[r_i] + ranges[r_i]; ++i){ if(!clouds.containsKey(i)) clouds.put(i, (long)1); else clouds.put(i, clouds.get(i) + 1); } } long result = maximumPeople(y,ranges); System.out.println(result); in.close(); } }