Hero is inviting his friends to the party.
He has n friends, numbered 0 through n-1.
For each of his friends there is at most one other person the friend dislikes.
You are given this information as a int a with n elements.
For each i, a[i] is either the number of the person disliked by friend i, we have a[i]=i if friend i likes everybody else.
Hero is inviting his friends one at a time.
Whenever he invites friend i, they will accept if and only if the friend a[i] didn't accept an earlier invitation.
(That includes two cases: either Hero didn't invite friend a[i] yet, or he did but the friend rejected the invitation.)
Hero noticed that the order in which he invites his friends matters: different orders may produce different numbers of accepted invitations.
He thought about finding the best order but the task was too hard for him.
Therefore he has decided that he will invite his friends in a randomly chosen order.
(Each permutation of his friends is equally likely to be chosen.)
Return the expected number of friends that will accept Hero's invitation.