$N = gets.to_i $e = gets.split(" ").map{|s| s.to_i} def search(a, b, c, i) return true if i == $N v = $e[i] if a + v <= $target then return true if search(a+v, b, c, i+1) end if b + v <= $target then return true if search(a, b+v, c, i+1) end if c + v <= $target then return true if search(a, b, c+v, i+1) end return false end sum = $e.sum if sum % 3 != 0 then puts "No" else $target = sum / 3 puts search(0, 0, 0, 0) ? "Yes" : "No" end