# Ruby, 41 characters <!-- language: lang-ruby --> ->a{m=a[0];a.map{|n|m>n ?p: m=n}.compact} Sample run: 2.1.5 :001 > [ 2.1.5 :002 > [1, 2, 5, 4, 3, 7], 2.1.5 :003 > [10, -1, 12], 2.1.5 :004 > [-7, -8, -5, 0, -1, 1], 2.1.5 :005 > [9, 8, 7, 6, 5], 2.1.5 :006 > [10, 13, 17, 21], 2.1.5 :007 > [10, 10, 10, 9, 10], 2.1.5 :008 > ].each{ |test| p ->a{m=a[0];a.map{|n|m>n ?p: m=n}.compact}[test] } [1, 2, 5, 7] [10, 12] [-7, -5, 0, 1] [9] [10, 13, 17, 21] [10, 10, 10, 10]