import sys

input = sys.stdin.readline

n = int(eval(input()))

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

M = sum(A)



s = 1 << M

for a in A:

  s |= s >> a

ans = bin(s)[2+(M+1)//2:].find("1") + (M+1)//2

print(ans)
import sys

input = sys.stdin.readline



n = int(eval(input()))

A = tuple(map(int, input().split()))

M = sum(A)

l = -(-M//2)

dp = 1

mask = (1<<(2*M))-1

for a in A:

  dp |= (dp<<a)&mask

dp >>= l

ans = (dp&(-dp)).bit_length() - 1 + l

print(ans)
import sys

input = sys.stdin.readline
n = int(eval(input()))
A = list(map(int, input().split()))
M = sum(A)
s = 1 << M
for a in A:
    s |= s >> a
ans = bin(s)[2 + (M + 1) // 2 :].find("1") + (M + 1) // 2
print(ans)

import sys

input = sys.stdin.readline
n = int(eval(input()))
A = tuple(map(int, input().split()))
M = sum(A)
l = -(-M // 2)
dp = 1
mask = (1 << (2 * M)) - 1
for a in A:
    dp |= (dp << a) & mask
dp >>= l
ans = (dp & (-dp)).bit_length() - 1 + l
print(ans)

-A = list(map(int, input().split())) +A = tuple(map(int, input().split())) -s = 1 << M +l = -(-M // 2) +dp = 1 +mask = (1 << (2 * M)) - 1 -    s |= s >> a -ans = bin(s)[2 + (M + 1) // 2 :].find("1") + (M + 1) // 2 +    dp |= (dp << a) & mask +dp >>= l +ans = (dp & (-dp)).bit_length() - 1 + l