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][x]=1;d[i+1][x*a[i]]&&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])}