var n,i,x,j,t1,t2,re:longint;
f:array[0..100005]of longint;
begin
assign(input,'circlea.in');reset(input);
assign(output,'circlea.out');rewrite(output);
readln(n);
for i:=2 to n+1 do
begin
readln(x);
f[i]:=f[i-1]+x;
end;
j:=1; re:=0;
for i:=2 to n do
begin
t1:=f[i]-f[j];
t2:=f[n+1]-t1;
if t1>t2 then
begin
while t2<=t1 do
begin
if t2>re then re:=t2;
inc(j);
if j>=n then begin j:=n; break; end;
t1:=f[i]-f[j];
t2:=f[n+1]-t1;
if(t2>t1)and(t1>re) then re:=t1;
end;
end
else begin
while(t2>=t1)do
begin
if t1>re then re:=t1;
dec(j);
if j<=0 then begin j:=1; break; end;
t1:=f[i]-f[j];
t2:=f[n+1]-t1;
if(t2<t1)and(re<t2)then re:=t2;
end;
end;
end;
writeln(re);
close(input);close(output);
end.