from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]

if n % 3 or len(set(a)) == 1:
    print('Yes' if len(set(a)) == 1 else 'No')
else:
    d = Counter()
    for x in a:
        d[x] += 1
    if len(d.keys()) == 2:
        print('Yes' if a.count(a[0]) in [n//3, 2 * n//3] else 'No')
        exit()
    for x in d.keys():
        if d[x] != n//3:
            print('No')
            exit()
    print('Yes')
