While entering random numbers in an array, my goal is to have a random number in element [x] different from the previous one [x-1] that's the only constraint. I believe to be achieving this but my problem is that when I run the following code my output does not display all elements.
        int[] array = new int[10];
        Random number = new Random();
        for(int i = 0; i < array.Length; i++)
        {
            int randomNumber = number.Next(3) + 1;
            if (i == 0)
            {
                array[0] = randomNumber;    
            }
            else
            {
                array[i] = randomNumber;
                while (array[i] == array[i - 1])
                {
                    array[i] = randomNumber;
                }
            }
            Console.Write(array[i] + " ");
        }
        Console.ReadLine();
 
    