#!/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. n = len(y) cloud_range = [0]*n town_sum = [0]*n sunny_people = 0 for i in range(n): left_ob = y[i]-r[i] right_ob = y[i]+r[i] for j in range(left_ob,right_ob+1): if j in x: j_index = x.index(j) x[j_index] = -10 town_sum[i] += p[j_index] p[j_index] = -1 dark_max = max(town_sum) for i in range(len(p)): if not(p[i] == -1): sunny_people += p[i] sunny_people += dark_max return sunny_people 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, y, r) print(result)