Permutation Swaps

For each k from 1 to n-1, count permutations reachable from A in exactly k swaps, modulo 1e9+7.

Hard8CombinatoricsDynamic programmingSortingNo attempts yetTime limit2sMemory limit512 MB

Problem

Consider a permutation of length nn in which every number from 11 to nn appears exactly once.

A swap takes the numbers at two different positions and exchanges them. You can apply several swaps to a permutation to obtain another permutation, and you may touch the same position more than once.

A permutation AA is given. For each kk with 1kn11 \le k \le n-1, count the permutations that can be turned into AA with exactly kk swaps. Fewer than kk swaps and more than kk swaps both fail to count. Identical permutations are counted once.

Input

The first line contains nn. (2n1052 \le n \le 10^5)

The second line contains the nn integers of the permutation AA, separated by spaces.

Output

Print n1n-1 numbers on one line, separated by spaces. The ii-th number is the count of distinct permutations that can be turned into AA with exactly ii swaps, modulo 109+710^9+7.

Hint

Take n=3n = 3 and A=(3,1,2)A = (3, 1, 2).

Each of (1,3,2)(1, 3, 2), (2,1,3)(2, 1, 3), (3,2,1)(3, 2, 1) becomes (3,1,2)(3, 1, 2) after one swap.

Each of (3,1,2)(3, 1, 2), (2,3,1)(2, 3, 1), (1,2,3)(1, 2, 3) becomes (3,1,2)(3, 1, 2) after two swaps.