uses crt;
var a:array[1..100]of integer;
n,i,s,max,k:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=0;
for i:=1 to n do
for j:=1 to n do
if i<=j then
begin
s:=0;
for k:=i to j do
s:=s+a[k];
if max<s then max:=s;
end;
writeln(max);
readln;
end.