Kangho's Invitations

Given each friend's single disliked friend, find the expected number of friends who accept when a uniformly random invitation order is used.

Medium6ProbabilityMathCombinatoricsNo attempts yetTime limit2sMemory limit512 MB

Problem

Kangho wants to invite NN friends to a party. The friends are numbered 00 through N1N-1.

Each friend dislikes at most one other friend. The friend that friend ii dislikes is AiA_i, and if AiA_i equals ii, then friend ii dislikes nobody.

Kangho invites the friends one at a time. Friend ii accepts the invitation only if friend AiA_i has not been invited yet, or friend AiA_i was already invited and refused. In other words, friend ii refuses exactly when friend AiA_i was invited earlier and accepted.

The number of friends who accept depends on the order of the invitations. Kangho therefore picks one of the N!N! orders uniformly at random and invites the friends in that order.

Write a program that computes the expected number of friends who accept the invitation.

Input

The first line contains the number of friends NN (1N501 \le N \le 50).

The second line contains A0,A1,,AN1A_0, A_1, \dots, A_{N-1}, separated by spaces (0AiN10 \le A_i \le N-1).

Output

Print the expected number of friends who accept, rounded to ten digits after the decimal point, on one line. Print exactly ten digits after the point, keeping trailing zeros. No answer in the test data lies on a rounding boundary.

Note

Take N=3N = 3 with A0=0A_0 = 0, A1=1A_1 = 1, A2=1A_2 = 1. Friends 00 and 11 dislike nobody, and friend 22 dislikes friend 11. There are six orders. With the order (1,0,2)(1, 0, 2), friends 11 and 00 accept but friend 22 refuses. With the order (2,1,0)(2, 1, 0), all three accept. Averaging over all six orders gives an expected value of 2.52.5.