a = vector(1 000);
nb = 0;		\\ number of known values
last = -1;	\\ last value
notice(v) = nb++; last = v; if (nb<=#a, a[nb] = v; print (nb " " v));

{

	r = 1;		\\ index of run to process
	while (nb < #a,
		first = if (last==1, 3, 1);
		notice(first);
		len = a[r];
		for (k=1, len-1, notice(first + k));
		r++;
	)
}

quit