#!/bin/python3 import sys def maximumPeople(p, x, m, y, r): result = 0 temporary = 0 list = [] if m == 1: for i in p: result += i return result for i in range(m): for j in range(n): if y[i]-r[i]<=x[j] and y[i]+r[i]>=x[j]: temporary += p[j] else: result += p[j] list.append(temporary) temporary = list[0] for i in list: if i > temporary: temporary = i return result + temporary 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, m, y, r) print(result)