package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Scan()
	N, _ := strconv.Atoi(stdin.Text())
	stdin.Scan()
	hats := []int{}
	eqmap := map[int]bool{}
	for _, istr := range strings.Split(stdin.Text(), " ") {
		num, _ := strconv.Atoi(istr)
		hats = append(hats, num)
		eqmap[num] = true
	}
	for index := 0; index < N; index++ {
		if eqmap[hats[(N+index-1)%len(hats)]^hats[(N+index+1)%len(hats)]] {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}