//httips://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")
    };
}

//


//固定長
#[derive(Clone)]
struct BitSet {
    size: usize,
    a: Vec<usize>,
}

fn quot_rem(n: usize) -> (usize, usize) {
    let w = 8 * std::mem::size_of::<usize>();
    (n / w, n % w)
}

impl BitSet {
    fn new(size: usize) -> Self {
        let w = 8 * std::mem::size_of::<usize>();
        BitSet {
            size: size,
            a: vec![0; (size + w - 1) / w],
        }
    }
    fn set_at(&mut self, x: usize) {
        assert!(x < self.size);
        let (q, r) = quot_rem(x);
        self.a[q] |= 1 << r;
    }
    fn get_at(&self, x: usize) -> usize {
        assert!(x < self.size);
        let (q, r) = quot_rem(x);
        (self.a[q] >> r) & 1
    }
    fn fix(&mut self) {
        let (q, r) = quot_rem(self.size);
        if r != 0 {
            self.a[q] &= (1 << r) - 1;
        }
    }
    fn clear(&mut self) {
        let len = self.a.len();
        self.a.clear();
        self.a.resize(len, 0);
    }
}

use std::ops::*;

impl<'a> BitAndAssign<&'a BitSet> for BitSet {
    fn bitand_assign(&mut self, rhs: &'a Self) {
        assert!(self.size == rhs.size);
        for (a, b) in self.a.iter_mut().zip(rhs.a.iter()) {
            *a &= *b;
        }
    }
}

impl BitAndAssign for BitSet {
    fn bitand_assign(&mut self, rhs: Self) {
        *self &= &rhs;
    }
}

impl BitAnd for BitSet {
    type Output = Self;
    fn bitand(mut self, rhs: Self) -> Self {
        self &= &rhs;
        self
    }
}

impl<'a> BitAnd<&'a BitSet> for BitSet {
    type Output = Self;
    fn bitand(mut self, rhs: &'a Self) -> Self {
        self &= rhs;
        self
    }
}

impl<'a> BitOrAssign<&'a BitSet> for BitSet {
    fn bitor_assign(&mut self, rhs: &'a Self) {
        assert!(self.size == rhs.size);
        for (a, b) in self.a.iter_mut().zip(rhs.a.iter()) {
            *a |= *b;
        }
    }
}

impl BitOrAssign for BitSet {
    fn bitor_assign(&mut self, rhs: Self) {
        *self |= &rhs;
    }
}

impl<'a> BitOr<&'a BitSet> for BitSet {
    type Output = Self;
    fn bitor(mut self, rhs: &'a Self) -> Self {
        self |= rhs;
        self
    }
}

impl BitOr for BitSet {
    type Output = Self;
    fn bitor(mut self, rhs: Self) -> Self {
        self |= &rhs;
        self
    }
}

impl ShlAssign<usize> for BitSet {
    fn shl_assign(&mut self, rhs: usize) {
        let (q, r) = quot_rem(rhs);
        if q >= self.a.len() {
            self.clear();
            return;
        }
        if r == 0 {
            let a = &mut self.a;
            for i in (q..a.len()).rev() {
                a[i] = a[i - q];
            }
        } else {
            let w = 8 * std::mem::size_of::<usize>();
            let a = &mut self.a;
            for i in ((q + 1)..a.len()).rev() {
                let x = a[i - q];
                let y = a[i - q - 1];
                a[i] = (x << r) | (y >> (w - r));
            }
            a[q] = a[0] << r;
        }
        for i in (0..q).rev() {
            self.a[i] = 0;
        }
        self.fix();
    }
}

impl Shl<usize> for BitSet {
    type Output = Self;
    fn shl(mut self, rhs: usize) -> Self {
        self <<= rhs;
        self
    }
}

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let sum = a.iter().fold(0, |s, a| s + *a);
    let mut bit = BitSet::new(sum + 1);
    bit.set_at(0);
    for a in a {
        bit |= bit.clone() << a;
    }
    let mut ans = (sum + 1) / 2;
    while bit.get_at(ans) == 0 {
        ans += 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 6396