# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))
for i in range(1, N-1, 1):
    if not a[i-1] ^ a[i+1] == i:
        print("No")
        exit()

if not a[N-1] ^ a[1] == 1:
    print("No")
    exit()
elif not a[N-2] ^ a[0]  == N:
    print("No")
    exit()
print("Yes")