//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 100010001; const ll LINF = (ll)INF*INF*10; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} const int X = 1e5+1; //head int n; int tot; int a[50]; bitset dp[51]; bitset *now, *pre; vi pl[50]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; cin >> tot; rep(i, n) cin >> a[i]; dp[0].set(0); now = dp+1; pre = dp; rep(i, n) { rep(j, X) { if(pre->test(j)) { if(j+a[i] < X) now->set(j+a[i]); if(ll(j)*a[i] < X) now->set(j*a[i]); } } pre = now; now++; } pl[n-1].emplace_back(tot); for(int i = n-2; i >= 0; i--) { for(int x:pl[i+1]) { if(x > a[i+1] and dp[i+1].test(x-a[i+1])) pl[i].emplace_back(x-a[i+1]); if(x%a[i+1] == 0 and dp[i+1].test(x/a[i+1])) pl[i].emplace_back(x/a[i+1]); } } int now = a[0]; rep(i, n-1) { if(find(all(pl[i+1]), now+a[i+1]) != pl[i+1].end()) { now += a[i+1]; cout << '+'; } else { now *= a[i+1]; cout << '*'; } } cout << endl; }