gets l=$<.map{|i|eval i.split*'+4*'} s=0;l.map{|j|(d=l.max-j)%2<1?s+=d/2 :s=-1} p s