import sys

inputs = sys.stdin.readlines()



N = int(inputs[0])

a_list = list(map(int, inputs[1].split()))



from collections import Counter



def all_zeros(a_list):

    return sum(a_list) == 0



def check(N, a_list):

    if all_zeros(a_list):

        print('Yes')

        return

    elif N % 3 == 0:

        x = N // 3

        if not all([v % x == 0 for v in list(Counter(a_list).values())]):

            print('No')

            return

        while not all_zeros(a_list):

            counter = Counter([a & 1 for a in a_list])

            if counter[0] == x or counter[0] == N:

                a_list = [a >> 1 for a in a_list]

            else:

                print('No')

                return

        print('Yes')

    else:

        print('No')



check(N, a_list)
import sys

inputs = sys.stdin.readlines()



from collections import Counter



N = int(inputs[0])

a_list = list(map(int, inputs[1].split()))



def check(N, a_list):

    mc = Counter(a_list).most_common()

    n = len(mc)

    if n == 1:

        if mc[0][0] == 0:

            print('Yes')

            return

    elif n == 2:

        if mc[0][1] == 2*N // 3 and mc[1][0] == 0:

            print('Yes')

            return

    elif n == 3:

        if mc[0][1] == mc[1][1] == mc[2][1] and mc[0][0] ^ mc[1][0] ^ mc[2][0] == 0:

            print('Yes')

            return

    print('No')



check(N, a_list)
import sys

inputs = sys.stdin.readlines()
N = int(inputs[0])
a_list = list(map(int, inputs[1].split()))
from collections import Counter


def all_zeros(a_list):
    return sum(a_list) == 0


def check(N, a_list):
    if all_zeros(a_list):
        print("Yes")
        return
    elif N % 3 == 0:
        x = N // 3
        if not all([v % x == 0 for v in list(Counter(a_list).values())]):
            print("No")
            return
        while not all_zeros(a_list):
            counter = Counter([a & 1 for a in a_list])
            if counter[0] == x or counter[0] == N:
                a_list = [a >> 1 for a in a_list]
            else:
                print("No")
                return
        print("Yes")
    else:
        print("No")


check(N, a_list)

import sys

inputs = sys.stdin.readlines()
from collections import Counter

N = int(inputs[0])
a_list = list(map(int, inputs[1].split()))


def check(N, a_list):
    mc = Counter(a_list).most_common()
    n = len(mc)
    if n == 1:
        if mc[0][0] == 0:
            print("Yes")
            return
    elif n == 2:
        if mc[0][1] == 2 * N // 3 and mc[1][0] == 0:
            print("Yes")
            return
    elif n == 3:
        if mc[0][1] == mc[1][1] == mc[2][1] and mc[0][0] ^ mc[1][0] ^ mc[2][0] == 0:
            print("Yes")
            return
    print("No")


check(N, a_list)

+from collections import Counter + -from collections import Counter - - -def all_zeros(a_list): -    return sum(a_list) == 0 -    if all_zeros(a_list): -        print("Yes") -        return -    elif N % 3 == 0: -        x = N // 3 -        if not all([v % x == 0 for v in list(Counter(a_list).values())]): -            print("No") +    mc = Counter(a_list).most_common() +    n = len(mc) +    if n == 1: +        if mc[0][0] == 0: +            print("Yes") -        while not all_zeros(a_list): -            counter = Counter([a & 1 for a in a_list]) -            if counter[0] == x or counter[0] == N: -                a_list = [a >> 1 for a in a_list] -            else: -                print("No") -                return -        print("Yes") -    else: -        print("No") +    elif n == 2: +        if mc[0][1] == 2 * N // 3 and mc[1][0] == 0: +            print("Yes") +            return +    elif n == 3: +        if mc[0][1] == mc[1][1] == mc[2][1] and mc[0][0] ^ mc[1][0] ^ mc[2][0] == 0: +            print("Yes") +            return +    print("No")