#C2809. Equalize the Array Elements

    ID: 46166 Type: Default 1000ms 256MiB

Equalize the Array Elements

Equalize the Array Elements

You are given an array of integers. For each element, you can perform at most one operation: increment by 1, decrement by 1, or leave it unchanged. Determine whether it is possible to make all elements in the array equal. In other words, you need to check if all elements of the array can be equalized by applying at most a single unit change on each element.

Note: This is equivalent to verifying if the difference between the maximum and minimum element of the array satisfies (\max(A) - \min(A) \le 1), where (A) is the array of integers.

inputFormat

The first line contains a single integer (n) ((1 \le n \le 10^5)) representing the number of elements in the array. The second line contains (n) space-separated integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le 10^9)).

outputFormat

Print a single line containing either "Yes" if it is possible to make all elements equal under the given constraint, or "No" otherwise.## sample

3
1 2 3
No

</p>