#!/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. population = [] for i in range(len(y)): pop = 0 for j in range((y[i]-r[i]), (y[i]+r[i]+1)): if j in x: pop += p[x.index(j)] population.append(pop) maxpop = max(population) t = 0 for i in range(len(x)): for j in range(len(y)): lst = [x for x in range((y[j]-r[j]), (y[j]+r[j]+1))] if x[i] not in lst: t += p[i] return (maxpop+t) if __name__ == "__main__": n = int(input().strip()) #no of towns p = list(map(int, input().strip().split(' '))) #population x = list(map(int, input().strip().split(' '))) #locatioj of town m = int(input().strip()) #no of clouds y = list(map(int, input().strip().split(' '))) #locatuon of cloud r = list(map(int, input().strip().split(' '))) #range result = maximumPeople(p, x, y, r) print(result)