Pagini recente » Cod sursa (job #424864) | Cod sursa (job #1828263) | Cod sursa (job #2750664) | Cod sursa (job #1962933) | Cod sursa (job #320080)
Cod sursa(job #320080)
var ok:boolean;
f:text;
n,op,x,i,max:longint;
begin
assign(f,'operatii.in');
reset(f);
readln(f,n);
ok:=false;
op:=0;
max:=0;
for i:=1 to n do begin
read(f,x);
if (x<>0) and not ok then begin
ok:=true;
max:=x;
end
else
if (x<>0) and ok then begin
if x>max then max:=x;
end
else
if x=0 then begin
ok:=false;
op:=op+max;
max:=0;
end;
end;
close(f);
op:=op+max;
assign(f,'operatii.out');
rewrite(f);
write(f,op);
close(f);
end.