#!/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. location = {0:0} for i in range(len(p)): location[x[i]] = p[i] noClouds = set(x) oneCloud = set() for i in range(len(y)): start = y[i] - r[i] end = y[i] + r[i] + 1 for j in range(start, end): if j in oneCloud: oneCloud.discard(j) elif j in noClouds: noClouds.discard(j) oneCloud.add(j) total = 0 for i in noClouds: total += location[i] maxPossible = 0 for i in oneCloud: maxPossible = max(maxPossible, location[i]) return total + maxPossible if __name__ == "__main__": n = int(input().strip()) # number of towns p = list(map(int, input().strip().split(' '))) # populations of each town x = list(map(int, input().strip().split(' '))) # locations of each town m = int(input().strip()) # number of clouds y = list(map(int, input().strip().split(' '))) # locations of each cloud r = list(map(int, input().strip().split(' '))) # range of each cloud result = maximumPeople(p, x, y, r) print(result)