Pagini recente » Cod sursa (job #96773) | Cod sursa (job #1745219) | Cod sursa (job #2917850) | Cod sursa (job #2869540) | Cod sursa (job #137965)
Cod sursa(job #137965)
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]>0) and (a[i]>max) 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.in') ;
rewrite(g) ;
writeln(g,rez()) ;
close(g) ;
end.