Puzzle
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
You're given N^2 decimal digits from 1 to 9.
Consider some arrangement of these digits in the cells of a square board N×N, one digit per cell. In each of the rows on the board, reading from left to right, we get a decimal representation of some N-digit number. In each of the columns, reading from top to bottom, we also get a decimal representation of an N-digit number. Let S be the sum of all N numbers in rows and all N numbers in columns.
Arrange the given digits on the board to make maximally possible.
Input
The first line of input contains integer N (1 ≤ N ≤ 8). In the second line, there are N^2 decimal digits from 1 to 9. written with no delimiters.
Output
Print the maximal possible value of the sum S.
Examples
Input #1
Answer #1
Submissions 60
Acceptance rate 30%