N = int(eval(input()))

A = [int(a) for a in input().split()]

s = 1

for a in A:

    s |= s << a



for i in range((sum(A)+1)//2, sum(A)+1):

    if s & (1<<i):

        print(i)

        break
N = int(eval(input()))

A = [int(a) for a in input().split()]

s = 1

for a in A:

    s |= s << a



ss = bin(s)

for i in range((sum(A)+1)//2, sum(A)+1):

    if ss[-i-1] == "1":

        print(i)

        break
N = int(eval(input()))
A = [int(a) for a in input().split()]
s = 1
for a in A:
    s |= s << a
for i in range((sum(A) + 1) // 2, sum(A) + 1):
    if s & (1 << i):
        print(i)
        break

N = int(eval(input()))
A = [int(a) for a in input().split()]
s = 1
for a in A:
    s |= s << a
ss = bin(s)
for i in range((sum(A) + 1) // 2, sum(A) + 1):
    if ss[-i - 1] == "1":
        print(i)
        break

+ss = bin(s) -    if s & (1 << i): +    if ss[-i - 1] == "1":