import std.stdio, std.conv, std.string, std.bigint; import std.math, std.random, std.datetime; import std.array, std.range, std.algorithm, std.container; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } void main(){ int n = read.to!int; int total = read.to!int; int[] as = readln.chomp.split.map!(to!int).array; int m = n / 2; uint[int] xs; xs[as[0]] = 0; foreach(a; as[1 .. m]){ uint[int] xs_new; foreach(k; xs.keys){ if(k + a <= total) if(k + a !in xs_new || xs_new[k + a] > xs[k] * 2 + 0) xs_new[k + a] = xs[k] * 2 + 0; if(k * a <= total) if(k * a !in xs_new || xs_new[k * a] > xs[k] * 2 + 1) xs_new[k * a] = xs[k] * 2 + 1; } xs = xs_new; } debug xs.writeln; uint[int] ys; ys[total] = 0; foreach_reverse(a; as[m .. n]){ uint[int] ys_new; foreach(k; ys.keys){ if(k - a >= 0) if(k - a !in ys_new || ys_new[k - a] > ys[k] * 2 + 0) ys_new[k - a] = ys[k] * 2 + 0; if(k % a == 0) if(k / a !in ys_new || ys_new[k / a] > ys[k] * 2 + 1) ys_new[k / a] = ys[k] * 2 + 1; } ys = ys_new; } debug ys.writeln; int[] kxs = xs.keys; kxs.sort(); foreach(k; kxs){ if(k in ys){ string ans; foreach_reverse(i; 0 .. m - 1) if((1 << i) & xs[k]) ans ~= "*"; else ans ~= "+"; foreach(i; 0 .. n - m) if((1 << i) & ys[k]) ans ~= "*"; else ans ~= "+"; ans.writeln; break; } } return; }