#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

struct Random {
    x: i32,
    y: i32,
    z: i32,
    w: i32,
    t: i32,
}

impl Random {
    fn new() -> Random {
        Random {
            x: 400,
            y: 362436069,
            z: 521288629,
            w: 886751233,
            t: 1,
        }
    }

    fn next(&mut self) -> i32 {
        self.t = self.x^(self.x << 11);
        self.x = self.y;
        self.y = self.z;
        self.z = self.w;
        self.w = (self.w ^ (self.w>>19)) ^ (self.t ^ (self.t>>8));
        self.w&0x7fffffff
    }

    fn shuffle<T>(&mut self, v: &mut Vec<T>) {
        for i in (1..v.len()).rev() {
            let j = self.next()%i as i32;
            let j = j as usize;
            v.swap(i, j);
        }
    }

}


fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    
    let n = readl!(usize);
    let mut a = readlvec!(i32);

    let mut rnd = Random::new();
    rnd.shuffle(&mut a);
    let len = 1_000_00;
    let mut dp = vec![false; len];
    dp[0] = true;
    for &e in &a {
        let mut nex = vec![false; len];
        for i in 0..nex.len() as i32 {
            if dp[i as usize] {
                let l = (i-e).abs();
                let h = i+e;
                if l < nex.len() as i32  {
                    nex[l as usize] = true;
                }
                if h < nex.len() as i32 {
                    nex[h as usize] = true;
                }
            }
        }
        dp = nex;
    }
    let sum: i32 = a.iter().cloned().sum();
    for i in 0..dp.len() {
        if dp[i] {
            printfln!("{}", (sum+i as i32)/2);
            return;
        }
    }
    unreachable!();
}


Measured memory_bytes: 4476