Problems
Number of permutation
Number of permutation
Given a permutation of $n$ numbers from $1$ to $n$. Find its number in the lexicographic order.
\InputFile
The first line contains the integer $n~(1 \le n \le 12)$. The next line contains the permutation of $n$ numbers.
\OutputFile
Print the permutation number in lexicographical order.
Input example #1
3 2 1 3
Output example #1
3