Finding the most frequent element in an array of numbers from 0 to n-1