How can I give an array of objects a variety of colors?
I think you need to apply your array modifier, and then separate by loose parts in edit mode.  Press P&gt;loose parts to do this.
Add an object info node to your material, and use the random output. This will assign each object assigned the material a color from the gradient.
A basic setup would look something like this:

This is an example of the effect with an arrayed Suzanne with setup shown: