Could say that but that’s why it doesn’t work. Array modifier does not array objects, it arrays object data (mesh). You have 1 object with 6 mesh parts, that object gets one object index (probably default 0) and dividing 0 with 0.6 gives 0, which is the first color in the ramp.
To add to other answers, could also do this with procedural duplication. Instead of arraying (mesh) this uses instances of objects and it’s possible to use parent’s coordinates to get a single color for each.
Duplifaces are used. Basically single planes where duplication puts a cube on each face. Those faces are UV unwrapped.
The material is for one cube and coordinates come from the parent object with the ‘dupli’ option. We’re only interested in U axis of UV coordinates. Top set of cubes uses the shown color ramp, bottom ones use different UV’s from parent and hue saturation node to get a different range of hues with an offset.
Array-6-colors-ja12.blend (93.8 KB)