import org.jetbrains.annotations.Mutable import java.io.* import java.util.InputMismatchException import java.io.IOException import javax.swing.text.MutableAttributeSet import kotlin.system.measureTimeMillis var out = PrintWriter(System.out) /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ fun solve() { var N = ni() var TOTAL = ni() var A = na(N) var dp = mutableMapOf(A[0] to "") for(i in 1 until N) { var pd: MutableMap = mutableMapOf() var x = A[i] for(p in dp) { var k = p.key var s = p.value // + if(k + x <= TOTAL) { var kk = k + x var ss = s + "+" if(!pd.containsKey(kk)) pd[kk] = ss else { var ks:String = pd[kk]!! if(ks < ss) pd[kk] = ss } } // * if(k.toLong() * x.toLong() <= TOTAL.toLong()) { var kk = k * x var ss = s + "*" if(!pd.containsKey(kk)) pd[kk] = ss else { var ks:String = pd[kk]!! if(ks < ss) pd[kk] = ss } } } dp = pd } out.println(dp[TOTAL]) } //--------------------------------------------------------------------------------------------------- fun main(args: Array) { var time = measureTimeMillis { solve() out.flush() } //println("$time ms") } //--------------------------------------------------------------------------------------------------- private var inbuf = ByteArray(1024) private var lenbuf = 0 var ptrbuf = 0 var `is` = System.`in` fun readByte(): Byte { if (lenbuf === -1) throw InputMismatchException() if (ptrbuf >= lenbuf) { ptrbuf = 0 try { lenbuf = `is`.read(inbuf) } catch (e: IOException) { throw InputMismatchException() } if (lenbuf <= 0) return -1 } return inbuf[ptrbuf++] } fun na(n: Int) = IntArray(n, {ni()}) fun ni(): Int { var num = 0 var b: Byte var minus = false while (true) { b = readByte() if(b < 0) break if(b >= '0'.toByte() && b <= '9'.toByte() || b == '-'.toByte()) break if (b == '-'.toByte()) { minus = true b = readByte() } } while (true) { if (b >= '0'.toByte() && b <= '9'.toByte()) { num = num * 10 + (b - '0'.toByte()) } else { return if (minus) -num else num } b = readByte() } }