#include typedef long long ll; typedef unsigned long long ull; #define FOR(i,a,b) for(int (i)=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define RANGE(vec) (vec).begin(),(vec).end() using namespace std; class Yuki0010 { public: void solve(void) { int N,Total; cin>>N>>Total; vector A(N); REP(i,N) cin>>A[i]; vector> dp(N+1, vector(Total+1, false)); dp[0][A[0]] = true; REP(i,N-1) { REP(s,Total+1) { if ( !dp[i][s] ) continue; int a = A[i+1]; if ( s+a <= Total ) dp[i+1][s+a] = true; if ( s*a <= Total ) dp[i+1][s*a] = true; } } vector ans; set vis; function collect = [&](int s, int k, string str) { if ( vis.count(str) ) return; vis.insert(str); if ( s > Total ) return; if ( k > N-1 ) return; if ( !dp[k][s] ) return; if ( k == N-1 ) { if ( s == Total ) { ans.push_back(str); return; } return; } collect(s+A[k+1], k+1, str+'+'); collect(s*A[k+1], k+1, str+'*'); }; collect(A[0], 0, ""); sort(RANGE(ans)); reverse(RANGE(ans)); cout<solve(); delete obj; return 0; } #endif