#!/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. towns = [0 for i in range(max(x) + 1)] max_p = 0 rainy_towns = [] for i in range(len(x)): towns[x[i]] = p[i] for i in range(len(y)): current_range = r[i] current_town = y[i] current_town_pop = towns[y[i]] temp_max_pop = 0 for i in range(current_town - current_range, current_town + current_range +1): try: temp_max_pop += towns[i] rainy_towns.append(i) except: continue if max_p < temp_max_pop: max_p = temp_max_pop rainy_towns = set(rainy_towns) towns_not_affected = [town_id for town_id in range(towns+1) if town_id not in rainy_towns] for pop in towns_not_affected: max_p += pop return max_p 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)