Add Again

Summation of sequence of integers is always a common problem in Computer Science. Rather than com- puting blindly, some intelligent techniques make the task simpler. Here you have to find the summation of a sequence of integers. The sequence is an interesting one and it is the all possible permutations of a given set of digits. For example, if the digits are <1 2 3>, then six possible permutations are <123>, <132>, <213>, <231>, <312>, <321> and the sum of them is 1332. Input Each input set will start with a positive integer N (1 ≤ N ≤ 12). The next line will contain N decimal digits. Input will be terminated by N = 0. There will be at most 20000 test set. Output For each test set, there should be a one line output containing the summation. The value will fit in 64-bit unsigned integer. Sample Input 3 123 3 112 0 Sample Output 1332 444