#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; int dp[55][100005]; int type[55][100005]; int main(){ int N, total, a; vector A; cin >> N; cin >> total; rep(i,N){ cin >> a; A.push_back(a); } dp[0][A[0]] = 1; REP(i,1,N){ rep(j,total+1){ if(dp[i-1][j] == 1){ if(j+A[i]<=total){ if(dp[i][j+A[i]] == 0){ dp[i][j+A[i]] = 1; type[i][j+A[i]] = 1; } else if(type[i][j+A[i]] == 2){ type[i][j+A[i]] = 3; } } if(j*A[i]<=total){ if(dp[i][j*A[i]] == 0){ dp[i][j*A[i]] = 1; type[i][j*A[i]] = 2; } else if(type[i][j+A[i]] == 1){ type[i][j+A[i]] = 3; } } } } } dp[N-1][total] = 2; for(int i=N-2; i>=0; i--){ rep(j,total+1){ if(j+A[i]<=total && dp[i+1][j+A[i]] == 2) dp[i][j] = 2; if(j*A[i]<=total && dp[i+1][j*A[i]] == 2) dp[i][j] = 2; } } vector ret; int n = A[0]; REP(i,1,N){ if(n+A[i]<=total && dp[i][n+A[i]] == 2){ ret.push_back(1); n += A[i]; }else if(n*A[i]<=total && dp[i][n*A[i]] == 2){ ret.push_back(2); n *= A[i]; } } rep(i,ret.size()){ if(ret[i] == 1){ cout << "+"; }else{ cout << "*"; } } cout << endl; return 0; }