#K67867. Equalizing Heights

    ID: 32738 Type: Default 1000ms 256MiB

Equalizing Heights

Equalizing Heights

You are given n individuals, each with a certain height. Your task is to determine whether it is possible to make all the individuals have the same height by applying a series of operations. After careful analysis, it can be determined that if the difference between the maximum height and the minimum height is at least 3, it becomes impossible to equalize all heights. Otherwise, if the maximum minus the minimum is less than 3, the heights can be made equal.

Mathematically, let (h_{\min}) be the minimum height and (h_{\max}) be the maximum height. The heights can be equalized if and only if (h_{\max} - h_{\min} < 3).

inputFormat

The input is provided via standard input (stdin). The first line contains an integer (T) which denotes the number of test cases. Each test case consists of two lines:

  1. The first line contains an integer (n), the number of individuals.
  2. The second line contains (n) space-separated integers representing the heights of the individuals.

outputFormat

For each test case, output a single line on standard output (stdout) containing either "YES" if it is possible to equalize the heights, or "NO" if it is not.## sample

3
5
2 3 2 3 2
4
4 4 4 4
5
1 2 3 4 5
YES

YES NO

</p>