Yaroslav has an array that consists of *n* integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time.

Help Yaroslav.
The first line contains integer *n* (1 ≤ *n* ≤ 100) — the number of elements in the array. The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 1000) — the array elements.
from sys import stdin, stdout
flag = False
def dfs(newArray, mark, pos):
    global flag
    if newArray[-1] != 0:
        flag = True
        return 1
    for i in range(n):
        if mark[i]:
            if pos > 0:
                if newArray[pos-1] != array[i]:
                    newArray[pos] = array[i]
                    mark[i] = 0
                    pos += 1
                    dfs(newArray, mark, pos)
                    pos-=1
                    newArray[pos] = 0
                    mark[i] = 1
            else:
                newArray[pos] = array[i]
                mark[i] = 0
                pos += 1
                dfs(newArray, mark, pos)
                pos-=1
                newArray[pos] = 0
                mark[i] = 1
    return 0
n = int(stdin.readline().rstrip())
array = stdin.readline().rstrip().split()
newArray, mark = [0]*n, [1]*n
dfs(newArray, mark, 0)
if flag:
    stdout.write('YES'+'\n')
else:
    stdout.write('NO'+'\n')

