f=->a{a.each_cons(2).map{|a,b|a*b!=0?0:a+b}.max}p f[gets.split.map(&:to_i)]
-11 0 0 0 0 0 -12 10
0
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!