#!/bin/python3 import sys def maximumPeople(p, x, y, r): # Return the maximum number of people that will be in a sunny town after removing exactly one cloud. totalPeople = 0 maxCity = 0 i = 0 j = 0 cloudrange = [] for yi in range(len(y)): cloudrange.append([y[yi] - r[yi], y[yi] + r[yi]]) cloudrange = sorted(cloudrange, key = lambda k : k[0]) #print(cloudrange) shadowSum = 0 while(i < len(y) and j < len(x)): shadowl = cloudrange[i][0] shadowr = cloudrange[j][1] if(shadowl <= x[j] and shadowr >= x[j]): maxCity = max(maxCity, p[j]) shadowSum += p[j] j += 1 elif(shadowr < x[j]): i += 1 return sum(p) - shadowSum + maxCity if __name__ == "__main__": n = int(input().strip()) p = list(map(int, input().strip().split(' '))) x = list(map(int, input().strip().split(' '))) m = int(input().strip()) y = list(map(int, input().strip().split(' '))) r = list(map(int, input().strip().split(' '))) result = maximumPeople(p, x, y, r) print(result)