The way I would do this is simple: sort the array.
When you do that, all the repeated elements are next to each other and very, very easy to spot in a single pass...
1, 3, 17, 17, 21, 22, 24, 24, 37, 42
All you need to do is check if the current value is the same as the last value and if it is, it's repeated.