eolymp
bolt
Try our new interface for solving problems
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.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3
2 1 3
Output example #1
3