#!/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. sunnyCityPop = 0 sunnyCities = [True]*len(p) # Find cities not affected at all by any cloud for i in range(len(p)): for j in range(len(y)): left = 0 right = 0 left = y[j] - r[j] right = y[j] + r[j] if x[i] >= left and x[i] <= right: # city is NOT safe from this cloud sunnyCities[i] = False for i in range(len(sunnyCities)): if sunnyCities[i] == True: sunnyCityPop += p[i] max = -float("inf") #Checking clouds for i in range(len(y)): populationAffected = sunnyCityPop l = y[i] - r[i] r = y[i] + r[i] #Going over cities now for j in range(len(p)): if sunnyCities[j] == True: continue if x[i] >= l and x[i] <= r: populationAffected += p[j] if populationAffected > max: max = populationAffected return max if __name__ == "__main__": n = int(input().strip()) #number of cities p = list(map(int, input().strip().split(' '))) # city populations x = list(map(int, input().strip().split(' '))) # city locations m = int(input().strip()) # number of clouds y = list(map(int, input().strip().split(' '))) # location of clouds r = list(map(int, input().strip().split(' '))) # cloud range result = maximumPeople(p, x, y, r) print(result)