Split[{1, 1, 2, 1, 1, 1, 2, 2, 1, 2, 1}, SameQ] /. {x : {1 ..} :> Length[x]} /. {x : {2 ..} :> Sequence @@ ConstantArray[0, Length[x] - 1]} Note: your example has no divider as the first or last element. If an initial or final sequence of 1s can be empty -- that is, if the first or last element can be a bin divider -- the answer changes