You are given N integers A_1, A_2, ..., A_N.

Consider the sums of all non-empty subsequences of A. There are 2^N - 1 such sums, an odd number.

Let the list of these sums in non-decreasing order be S_1, S_2, ..., S_{2^N - 1}.

Find the median of this list, S_{2^{N-1}}.

Constraints

* 1 \leq N \leq 2000
* 1 \leq A_i \leq 2000
* All input values are integers.

Input

Input is given from Standard Input in the following format:


N
A_1 A_2 ... A_N


Output

Print the median of the sorted list of the sums of all non-empty subsequences of A.

Examples

Input

3
1 2 1


Output

2


Input

1
58


Output

58
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemC solver = new ProblemC();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}
			out.println(solve(a.clone()));

			boolean stress = false;
			if (stress) {
				Random random = new Random(0);
				for (int it = 0; it < 100; it++) {
					n = random.nextInt(15) + 1;
					a = new int[n];
					for (int i = 0; i < n; i++) {
						a[i] = random.nextInt(2000) + 1;
					}
					int u = solve(a.clone());
					int v = slow(a.clone());
					if (u != v) {
						throw new AssertionError(Arrays.toString(a));
					}
				}
			}
		}

		private int solve(int[] a) {
			int sum = 0;
			for (int x : a) {
				sum += x;
			}
			BigInteger b = BigInteger.ONE;
			for (int x : a) {
				b = b.or(b.shiftLeft(x));
			}
			for (int i = (sum + 1) / 2; ; i++) {
				if (b.testBit(i)) {
					return i;
				}
			}
		}

		private int slow(int[] a) {
			int n = a.length;
			int[] s = new int[1 << n];
			for (int i = 1; i < s.length; i++) {
				int j = Integer.numberOfTrailingZeros(i);
				s[i] = s[i ^ (1 << j)] + a[j];
			}
			Arrays.sort(s);
			return s[1 << (n - 1)];
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}

