#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, total; cin >> n >> total; vector a(n); for (int& x : a) cin >> x; // dp[i][x]: // a[0] ... a[i] まで計算した結果が x のとき、 // 残りを使って total にできるか vector> dp(n, vector(total + 1)); dp[n - 1][total] = true; for (int i = n - 2; i >= 0; --i) { for (int x = 1; x <= total; ++x) { int add = x + a[i + 1]; if (add <= total and dp[i + 1][add]) { dp[i][x] = true; } long long mul = 1LL * x * a[i + 1]; if (mul <= total and dp[i + 1][mul]) { dp[i][x] = true; } } } string ans; int cur = a[0]; for (int i = 0; i + 1 < n; ++i) { int add = cur + a[i + 1]; // '+' で完成可能なら辞書順のために優先する if (add <= total and dp[i + 1][add]) { ans += '+'; cur = add; } else { ans += '*'; cur *= a[i + 1]; } } cout << ans << '\n'; }