mod bitset {
    const W: usize = 64;
//    const W: usize = 8 * std::mem::size_of::<usize>();
    #[derive(Clone)]
    pub struct BitSet {
        size: usize,
        a: Vec<usize>,
    }
    fn qr(x: usize) -> (usize, usize) {
        (x / W, x % W)
    }
    impl BitSet {
        pub fn new(n: usize) -> Self {
            BitSet {
                size: n,
                a: vec![0; (n + W - 1) / W],
            }
        }
        pub fn get_size(&self) -> usize {
            self.size
        }
        pub fn set_at(&mut self, x: usize) {
            debug_assert!(x < self.size);
            let (q, r) = qr(x);
            self.a[q] |= 1 << r;
        }
        pub fn get_at(&self, x: usize) -> bool {
            debug_assert!(x < self.size);
            let (q, r) = qr(x);
            ((self.a[q] >> r) & 1) == 1
        }
    }
    use std::ops::{Shl, BitOr};
    impl BitOr for BitSet {
        type Output = Self;
        fn bitor(self, rhs: BitSet) -> BitSet {
            let (mut x, y) = if self.size > rhs.size {(self, rhs)} else {(rhs, self)};
            for (t, f) in x.a.iter_mut().zip(y.a.iter()) {
                *t |= *f;
            }
            x
        }
    }
    impl Shl<usize> for BitSet {
        type Output = Self;
        fn shl(self, rhs: usize) -> BitSet {
            let n = self.size;
            let m = n + rhs;
            let mut next = BitSet::new(m);
            let (q, r) = qr(rhs);
            if r == 0 {
                for (t, f) in next.a[q..].iter_mut().zip(self.a.iter()) {
                    *t = *f;
                }
                return next;
            }
            next.a[q] |= self.a[0] << r;
            let mut prev = self.a[0];
            for (t, f) in next.a[(q + 1)..].iter_mut().zip(self.a[1..].iter()) {
                *t = (*f << r) | (prev >> (W - r));
                prev = *f;
            }
            let l = next.a.len();
            next.a[l - 1] |= prev >> (W - r);
            next
        }
    }
}

//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn main(){
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut b = bitset::BitSet::new(1);
    b.set_at(0);
    for a in a {
        b = b.clone() | (b << a);
    }
    let mut ans = (b.get_size() - 1 + 1) / 2;
    while !b.get_at(ans) {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444