import Data.Maybe
import Data.List
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b
half = flip div 2
aliq = ((0==).).mod

xor :: [Bool] -> [Bool] -> [Bool]
xor [] [] = []
xor a [] = xor a [True]
xor [] b = xor [True] b
xor a b = [b'?(a',not a')] ++ xor as bs where
 a' = head a
 b' = head b
 as = tail a
 bs = tail b

i2b :: Int -> [Bool]
i2b n = [even n] ++ (n==0)?([],i2b (half n))

b2i :: [Bool] -> Int
b2i s = f 0 $ reverse s where
 f ans (a:as) = (null as)?(ans',f ans' as) where
  ans' = 2 * ans + a?(0,1)

exor a b = b2i (xor (i2b a) (i2b b))

main = do
  getLine
  inputs <- readLnInt
  putStr $ (solve inputs)?("Yes","No")

solve s
 | procrust s = calc $ nub s
 | otherwise = False

calc s
 | length s > 3 = False
 | otherwise = check s

check [a,b,c] = c == (exor a b)
check [a,b] = any (==0) [a,b]
check [a] = a == 0

procrust s = (\x -> maximum x - minimum x) ls < 2 where
 ls = map length $ group $ sort s
