Change color of material on click going through a list

Can you explain how did you made that color array with default values?