# Here your code ! require "mathn" OPERATORS=[ "+", "\\-", "*", "/", "_" ] EXPRESSIONS=%w[ AxByCzD ((AxB)yC)zD (AxB)y(CzD) (Ax(ByC))zD Ax((ByC)zD) Ax(By(CzD)) ] def solve( *nums0 ) nums0.permutation(nums0.size) do |nums| OPERATORS.repeated_permutation(nums0.length-1).each do |ops| EXPRESSIONS.each do |exp| begin yield eval(exp.tr( "ABCDxyz", (nums+ops).join )) rescue SyntaxError, ZeroDivisionError end end end end end n = gets.to_i a = gets.split.map{|m|m.to_i} S = 1 << n flag = false S.times do |bit| x = [] y = [] c = 0 d = 0 n.times do |s| if (bit >> s).to_i % 2 == 0 x.push(a[s]) c += 1 else y.push(a[s]) d += 1; end end if c > 0 and d > 0 if !(enum_for(:solve, x).to_a - enum_for(:solve, y).to_a).empty? and !flag puts("YES") flag = true end end end if !flag puts("NO") end