To generate a given length of the array