Energy distribution of maxima and minima in a one-dimensional random system