#!/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. mas = [] nw = [] m = 0 for i in range(len(y)): mas.append(0) for i in range(len(x)): nw.append(0) for i in range(len(y)): for j in range(len(x)): if x[j] > y[i] - r[i] and x[j] < y[i] + r[i]: mas[i] += p[j] nw[j] += 1 q = mas.index(max(mas)) y.pop(q) r.pop(q) nw[q] = 0 for i in range(len(nw)): if nw[i] == 0: m += p[i] return m 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)