300673: CF128D. Numbers

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Numbers

题意翻译

>就是给你$n$个正整数数$(3 <= n <= 10^5)$ 每个正整数数都不超过$10^9$, 现在问是否能将这n个数排成一个环, 使得换上相邻两个数的差都是$1$ >author:清风ღ

题目描述

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?

输入输出格式

输入格式


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} $ .

输出格式


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).

输入输出样例

输入样例 #1

4
1 2 3 2

输出样例 #1

YES

输入样例 #2

6
1 1 2 2 2 3

输出样例 #2

YES

输入样例 #3

6
2 4 1 1 2 2

输出样例 #3

NO

Input

题意翻译

>就是给你$n$个正整数数$(3 <= n <= 10^5)$ 每个正整数数都不超过$10^9$, 现在问是否能将这n个数排成一个环, 使得换上相邻两个数的差都是$1$ >author:清风ღ

加入题单

算法标签: