Pagini recente » Cod sursa (job #2947034) | Cod sursa (job #2952609) | Cod sursa (job #2735549) | Cod sursa (job #1146358) | Cod sursa (job #137978)
Cod sursa(job #137978)
var
n,i:longint;
a:array[1..100000] of longint;
f,g:text;
function rez:longint;
var
i,s,max:longint;
begin
s:=0;
max:=0;
for i:= 1 to n do begin
if (a[i]>max) and (a[i]>0) then
max:=a[i]
else if a[i]=0 then
begin
s:=s+max;
max:=0;
end;
end;
rez:=s+max;
end;
begin
assign(f,'operatii.in');
reset(f);
readln(f,n);
for i:=1 to n do
read(f,a[i]);
close(f);
assign(g,'operatii.out');
rewrite(g);
writeln(g,rez);
close(g);
end.