gets t=gets.to_i a=gets.split.map &:to_i d=(0..n=a.size).map{[]} d[n][t]=1 n-=1 n.downto(2){|i|1.upto(t){|x|[x+a[i],x*a[i]].each{|y|d[i+1][y]&&d[i][x]=1}}} x=a[0] 1.upto(n){|i|d[i+1][x+a[i]]?(print'+';x+=a[i]):(print'*';x*=a[i])}