@n=gets.to_i @a=gets.chomp.split.map{|e| '('+e+')'} @op=['+', '-', '*'] @r=0 def rec(i, s) if i==@n @r=[@r, s].max return end @op.each do |e| next if e=='/' and @a[i]=='0' # p @a[i+1] rec(i+1, eval(s.to_s+e+@a[i])) end end rec(1, @a[0]) puts @r