#!/bin/python3 import sys def maximumPeople(p, x, y, r): noCloud = 0 visited = set() val = list() town = dict() for i, t in enumerate(x): town[t] = p[i] for i, cloud in enumerate(y): temp = 0 x1 = cloud - r[i] x2 = cloud + r[i] for x in range(x1, x2 + 1): if x in town: temp += town[x] if x not in visited: visited.add(x) val.append(temp) for key in town: if key not in visited: noCloud += town[key] return max(val) + noCloud if __name__ == "__main__": n = int(input().strip()) # number of towns p = list(map(int, input().strip().split(' '))) # people x = list(map(int, input().strip().split(' '))) # location of towns m = int(input().strip()) # number of clouds covering the city y = list(map(int, input().strip().split(' ')))# location of cloud r = list(map(int, input().strip().split(' ')))# range of the cloud result = maximumPeople(p, x, y, r) print(result)