Maximize stock by finding local maximums in an array