#!/bin/python3 import sys import operator def maximumPeople(n, p, x, m, y, r): # Return the maximum number of people that will be in a sunny town after removing exactly one cloud. d = {} pop = 0 for i in range(len(y)): for j in range(len(x)): pop += p[j] if y[i]+r[i] >= x[j] and y[i]-r[i] <= x[j]: pop -= p[j] if i not in d: d[i] = p[j] else: d[i] += p[j] else: pass dictlist=list(d.values()) dictlist.sort(reverse=True) return pop+dictlist[0] 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(n, p, x, m, y, r) print(result)