count number of duplicate elements in array python