This appears to be a continuation of a previous thread of yours:
http://forum.arduino.cc/index.php?topic=509022.msg3469822#msg3469822
Are you now simply looking now for transitions from rising to falling values ? If so, the example you have given would be:
345,380,420,455,455,455,455,455,365,397,385,399
R R R R R R R R F R F R
!!! !!!
F = less than previous value ie falling
R = rising ie not falling
!!! = transition R->F detected ie next value smaller than current.
You'll still have a problem though if your "flat top" has very slight "dents" in it. So you may have to apply some "smoothing" :
345,380,420,455,454,455,454,455,365,397,385,399
R R R R F R F R F R F R
!!! !!! !!! !!!
F = less than previous value ie falling
R = rising ie not falling
!!! = transition R->F detected