| Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Question by Renato Bala.
 
 
 Permutation of Everything   Combinatorics and Permutations are famous topics in mathematics. 
They get even more famous and fun when they are asked in homeworks. 
This exercise will ask you the permutation order number of the 
given digits.  
If we have a three digits number '123' the first permutation is the number 
itself. The second permuation is '132', the third is '213' and so on. 
It comes in lexicographical order. But these exercise unlike the other 
permutation exercises in ACM comes with repeated digits. For example: 
The given number is '1223',  the first permutation is the number itself, 
the second permutation is '1232', the third '1322', the fourth '2123'
and so on.
 Question:  Write a program that finds the 
permutation order number of the given digits.
 Input specification:  You will be given an n (1 ≤ n ≤ 20) that is the 
number of digits and n digits (0 ≤ digit ≤ 9).
 Output specification  Show a number the represents the order number of the permutation.
 
| Sample Input I 
 
42 1 3 2
 
 | Sample Input II 
 
5 5 4 3 1 2
 
 |  
| Sample Output I 5
 | Sample Output II 119
 |  Для отправки решений необходимо выполнить вход.
 
 
 |