Codeforces Beta Round 94 (Div. 1 Only)
D
Numbers
Codeforces
2000
原题
← CE →
翻译中…

One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if she had arranged the numbers correctly, but at this point her younger sister Maria came and shuffled all numbers. Anna got sick with anger but what's done is done and the results of her work had been destroyed. But please tell Anna: could she have hypothetically completed the task using all those given numbers?

翻译中…

Input

翻译中…

The first line contains an integer $*n*$ — how many numbers Anna had ($3 ≤ *n* ≤ 10^{5}$). The next line contains those numbers, separated by a space. All numbers are integers and belong to the range from $1$ to $10^{9}$.

翻译中…

Output

翻译中…

Print the single line "YES" (without the quotes), if Anna could have completed the task correctly using all those numbers (using all of them is necessary). If Anna couldn't have fulfilled the task, no matter how hard she would try, print "NO" (without the quotes).

翻译中…

样例

Input #1
4
1 2 3 2
Output #1
YES
InputCopy OutputCopy
Input #2
6
1 1 2 2 2 3
Output #2
YES
InputCopy OutputCopy
Input #3
6
2 4 1 1 2 2
Output #3
NO
InputCopy OutputCopy
题目信息
题号
128D
时间限制
2 s
内存限制
256 MB
标签
构造
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。