Count the Number of Ideal Arrays