uses crt;
var a,b:array[1..1000]of longint; d:text; i,j,n,k,t,kt,ktt:longint;
begin
clrscr;
assign(d,'input.pas');reset(d);
readln(d,n);
for i:=1 to n do read(d,a[i]);
k:=0;
for i:=1 to n do
begin
t:=0;
for j:=i to n do
begin
t:=t+a[j];
inc(k,3);
b[k-2]:=i;
b[k-1]:=i+j;
b[k]:=t;
end;
end;
// for i:=1 to k do write(b[i],';'); writeln;
kt:=0;
i:=0;
repeat
inc(i); ktt:=0;
for j:=1 to k do If i=b[j] then ktt:=1;
if ktt=0 then kt:=1;
until kt=1;
writeln(i);
close(d);
readln
end.