n = int(eval(input()))

a = list(map(int,input().split()))

s = sum(a)

a.sort()

b = 1

for i in a:

  b |= b<<i

  

b &= 2**(s+1)-2**((s-1)//2)

while True:

  t = b&(-b)

  #print(i,t,b)

  if (s+1)//2 <= t.bit_length()-1 <= s:

    print((t.bit_length()-1))

    break

  b ^= t
n = int(eval(input()))

a = list(map(int,input().split()))

s = sum(a)

a.sort()

b = 1

for i in a:

  b |= b<<i

  

b &= 2**(s+1)-2**((s-1)//2)

while True:

  t = b&(-b)

  T = t.bit_length()-1

  if (s+1)//2 <= T <= s:

    print(T)

    break

  b ^= t
n = int(eval(input()))
a = list(map(int, input().split()))
s = sum(a)
a.sort()
b = 1
for i in a:
    b |= b << i
b &= 2 ** (s + 1) - 2 ** ((s - 1) // 2)
while True:
    t = b & (-b)
    # print(i,t,b)
    if (s + 1) // 2 <= t.bit_length() - 1 <= s:
        print((t.bit_length() - 1))
        break
    b ^= t

n = int(eval(input()))
a = list(map(int, input().split()))
s = sum(a)
a.sort()
b = 1
for i in a:
    b |= b << i
b &= 2 ** (s + 1) - 2 ** ((s - 1) // 2)
while True:
    t = b & (-b)
    T = t.bit_length() - 1
    if (s + 1) // 2 <= T <= s:
        print(T)
        break
    b ^= t

-    # print(i,t,b) -    if (s + 1) // 2 <= t.bit_length() - 1 <= s: -        print((t.bit_length() - 1)) +    T = t.bit_length() - 1 +    if (s + 1) // 2 <= T <= s: +        print(T)