Strange_Permutations
题号:NC231086
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Given a permutation P of , determine the number of permutations Q satisfying that . Output the number modulo 998244353.

输入描述:

The first line contains one integer , denoting the size of given permutation.

The second line contains n integers , denoting the given permutation.

It is guaranteed that .

输出描述:

Output one line containing one integer, denoting the answer number modulo 998244353.
示例1

输入

复制
4
3 4 1 2

输出

复制
8

说明

The 8 permutations are:
\{1, 2, 3, 4\}
\{1, 4, 3, 2\}
\{2, 1, 4, 3\}
\{2, 3, 4, 1\}
\{3, 2, 1, 4\}
\{3, 4, 1, 2\}
\{4, 1, 2, 3\}
\{4, 3, 2, 1\}