eolymp
bolt
Try our new interface for solving problems
Problems

Number of permutation

Number of permutation

Time limit 1 second
Memory limit 64 MiB

Given a permutation of n numbers from 1 to n. Find its number in the lexicographic order.

Input data

The first line contains the integer n~(1 \le n \le 12). The next line contains the permutation of n numbers.

Output data

Print the permutation number in lexicographical order.

Examples

Input example #1
3
2 1 3
Output example #1
3