algorithm for finding a peak (only one) in an array