import sys input=lambda:sys.stdin.readline().rstrip() N=int(input()) A=list(map(lambda x:int(x)-1,input().split())) cycle=[0 for i in range(N+1)] checked=[0 for i in range(N)] for i in range(N): if not checked[i]: cnt,pt=0,i while not checked[A[pt]]: pt=A[pt] checked[pt]=1 cnt+=1 if cnt%2==0: cycle[cnt]=1-cycle[cnt] print(["Yes","No"][max(cycle)])