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|(d[i+1][x+a[i]]||d[i+1][x*a[i]])&&d[i][x]=1}} x=a[0] 1.upto(n){|i|f=d[i+1][y=x+a[i]];print f ??+:?*;x=f ?y:x*a[i]}