#!/bin/python3 import sys import operator def maximumPeople(p, x, y, r): # Return the maximum number of people that will be in a sunny town after removing exactly one cloud. #P - population of ith town #x - Locatioin of ith town #y - location of cloud on number line #r - range of ith cloud longest = r.index(max(r)) return y[longest] 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)