N = int(input())
A = list(map(int,input().split()))

if N%3 == 0:
    if len(set(A)) <= 3:
        print('Yes')
    else:
        print('No')

elif N%3 != 0:
    if len(set(A)) == 2 and 0 in A:
        print('Yes')
    elif len(set(A)) == 1 and 0 in A:
        print('No')
    else:
        print('No')
