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 = Array(N + 1, { Array(101010, {0}).toMutableList() }) var pre = Array>(N + 1, { Array(101010, {""}).toMutableList() }) dp[0][A[0]] = 1 for(i in 0 until N - 1) for(j in 0..100000) if(0 < dp[i][j]) { var x = A[i + 1] // + if(j + x < 101010) { dp[i + 1][j + x] = 1 if(pre[i + 1][j + x].length == 0) pre[i + 1][j + x] = pre[i][j] + "+" else if(pre[i][j] + "+" > pre[i + 1][j + x]) pre[i + 1][j + x] = pre[i][j] + "+" } // * if(j.toLong() * x.toLong() < 101010L) { dp[i + 1][j * x] = 1 if(pre[i + 1][j * x].length == 0) pre[i + 1][j * x] = pre[i][j] + "*" else if(pre[i][j] + "*" > pre[i + 1][j * x]) pre[i + 1][j * x] = pre[i][j] + "*" } } out.println(pre[N - 1][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() } }