You could change it to only add points to the array if the head is moving instead of every tick. Basically:
Compare: distance(head.x,head.y,array.at(0,0), array.at(0,1)) > 0
That would keep it from stacking on top of itself if it stopped. Possibly good enough.
It still doesn't work. :(
Whenever the enemy stands still in front of the player, the twelve objects accumulate in a single coordinate and I would actually like the objects to always maintain a distance between them in a straight horizontal line, forming a kind of "Chinese serpent".