I'm pretty sure you have to iterate over it at least twice. I guess the specification is implicit in that.
The worst case of the best algorithm is to iterate twice - firstly as above, and then again in the opposite direction, comparing values from the first iteration.