#!/usr/bin/env python3 import collections import functools import operator N = int(input()) a = [0] + list(map(int, input().split())) rest = list(range(len(a))) loop = collections.defaultdict(int) while True: if len(rest) == 0: break now = rest[0] count = 0 while True: rest.remove(now) now = a[now] count += 1 if now not in rest: loop[count] += 1 break for k, v in loop.items(): if k % 2 == 1 or v % 2 == 0: continue print("No") exit() print("Yes")