{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eYou\u0027re given \u003cstrong\u003eN^2\u003c/strong\u003e decimal digits from \u003cstrong\u003e1\u003c/strong\u003e to \u003cstrong\u003e9\u003c/strong\u003e.\u003c/p\u003e\n\n\u003cp\u003eConsider some arrangement of these digits in the cells of a square board \u003cstrong\u003eN\u003c/strong\u003e×\u003cstrong\u003eN\u003c/strong\u003e, one digit per cell. In each of the rows on the board, reading from left to right, we get a decimal representation of some \u003cstrong\u003eN\u003c/strong\u003e-digit number. In each of the columns, reading from top to bottom, we also get a decimal representation of an \u003cstrong\u003eN\u003c/strong\u003e-digit number. Let \u003cstrong\u003eS\u003c/strong\u003e be the sum of all \u003cstrong\u003eN\u003c/strong\u003e numbers in rows and all \u003cstrong\u003eN\u003c/strong\u003e numbers in columns.\u003c/p\u003e\n\n\u003cp\u003eArrange the given digits on the board to make maximally possible.\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eInput\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003eThe fi\u001crst line of input contains integer \u003cstrong\u003eN\u003c/strong\u003e (\u003cstrong\u003e1\u003c/strong\u003e ≤ \u003cstrong\u003eN\u003c/strong\u003e ≤ \u003cstrong\u003e8\u003c/strong\u003e). In the second line, there are \u003cstrong\u003eN^2\u003c/strong\u003e decimal digits from \u003cstrong\u003e1\u003c/strong\u003e to \u003cstrong\u003e9\u003c/strong\u003e. written with no delimiters.\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eOutput\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003ePrint the maximal possible value of the sum \u003cstrong\u003eS\u003c/strong\u003e.\u003c/p\u003e\n\n"}},{"title":"Example","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n9174\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e303\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}