add function for counting reapeat elements in an array