Pagini recente » Cod sursa (job #2099171) | Cod sursa (job #732695) | Cod sursa (job #1491914) | Cod sursa (job #672441) | Cod sursa (job #137976)
Cod sursa(job #137976)
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 then
max:=a[i]
else if a[i]=0 then
begin
s:=s+max;
max:=0;
end;
end;
s:=s+max;
rez:=s;
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.