Replicate the elements a given number of times