N = int(input())
a = list(map(int,input().split()))
x = [0,0]
y = [0,0]
z = [0,0]
Count = [0 for _ in range(3)]
Zero = 0
for i in range(N):
    if a[i] ==0:
        Zero += 1
    elif a[i] != x[0]:
        if x[1] == 0:
            x[0] = a[i]
            x[1] += 1
        elif a[i] != y[0]:
            if y[1] == 0:
                y[0] = a[i]
                y[1] += 1
            elif a[i] != z[0]:
                if z[1] == 0:
                    z[0] == a[i]
                    z[1] += 1
                else:
                    ans = 'No'
            else:
                z[1] += 1 
        else:
            y[1] += 1
    else:
        x[1] += 1

if Zero == N or (x[1] + Zero == N and Zero != 0) or (x[1] == y[1] == z[1] and x[1] + y[1] + z[1] == N):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)