Program bahe;
Var a:array[0..999]of boolean;
w:array[1..999]of integer;
n,total,max,i,j:integer;
Procedure Init;
Var i:integer;
Begin
Readln(n);
For i:=1 to n do
Begin
Readln(w);
Inc(total,w);
End;
total:=total div 2;
End;
Begin
Init;
max:=0;
Fillchar(a,sizeof(a),false);
a[0]:=true;
For i:=1 to n do
For j:=max downto 0 do
If (a[j])and(j+w<=total) then
Begin
a[j+w]:=true;
If j+w>max then max:=j+w;
End;
For i:=total downto 0 do
If a then
Begin
Writeln(2*(total-i));
Break;
End;
End.