if a[i]=0 then begin mas[z]:=i; memo2.lines.add(inttostr(mas[z])); // эта строка должна быть здесь z:=z+1; end;