How to change colors in turn?

I want to change colors in turn, white, yellow, orange, red, purple, blue, and black every time collision.
Now I use this random change code.

using UnityEngine;

public class ChangeColorOnHit : MonoBehaviour {
  void OnCollisionEnter(Collision collision) {
    var r = Random.Range(0f, 1f);
    var g = Random.Range(0f, 1f);
    var b = Random.Range(0f, 1f);
    GetComponent<Renderer>().material.color = new Color(r, g, b);
  }
}

I don’t know how to fix it.
Please someone help me?

using UnityEngine;

 public class ChangeColorOnHit : MonoBehaviour {
	 
	 // Define your colors in the inspector
	 public Color[] Colors = new Color[]
	 {
		 Color.white,
		 Color.yellow,
		 Color.red,
		 Color.black
	 };
	 
	 private int colorIndex = 0 ;
	 
   void OnCollisionEnter(Collision collision)
   {
     GetComponent<Renderer>().material.color = Colors[colorIndex];
	 colorIndex = (colorIndex + 1) % Colors.Length;
   }
 }