# -*- coding: utf-8 -*-
def main():
    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+1:
            print("No")
            exit()
    if not a[N-2] ^ a[0]  == N:
        print("No")
        exit()
    elif not a[N-1] ^ a[1] == 1:
        print("No")
        exit()
    print("Yes")

    # print(a[1] ^ a[2], a[0] ^ a[2], a[0] ^ a[1])

if __name__ == '__main__':
    main()