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