Check if element in array when iterating array. Respect holes