gets $t=gets.to_i a=gets.split.map(&:to_i) def dfs a,n if a[0] if dfs(a[1..-1],n+a[0]) print ?+ true elsif dfs(a[1..-1],n*a[0]) print ?* true end else n==$t end end dfs a[1..-1],a[0] puts