N=int(input()) S=[int(i)-1 for i in input().split()] L=[-1]*N s=1 for i in range(N): if L[i]==-1: s*=-1 while L[i]==-1:L[i]=0;i=S[i];s*=-1 print(s)