#Q1399A. Remove Smallest

Remove Smallest

Remove Smallest

题面翻译

给你一个 nn 个整数的数列,你可以每次选择满足一下条件的两个位置 i,ji,j

  • iji≠j
  • aiaj1|a_i-a_j| \le 1

然后删除 ai,aja_i,a_j 中较小的那一个。

问能否通过若干次操作将数列删除到只剩一个数。

题目描述

You are given the array a a consisting of n n positive (greater than zero) integers.

In one move, you can choose two indices i i and j j ( ij i \ne j ) such that the absolute difference between ai a_i and aj a_j is no more than one ( aiaj1 |a_i - a_j| \le 1 ) and remove the smallest of these two elements. If two elements are equal, you can remove any of them (but exactly one).

Your task is to find if it is possible to obtain the array consisting of only one element using several (possibly, zero) such moves or not.

You have to answer t t independent test cases.

输入格式

The first line of the input contains one integer t t ( 1t1000 1 \le t \le 1000 ) — the number of test cases. Then t t test cases follow.

The first line of the test case contains one integer n n ( 1n50 1 \le n \le 50 ) — the length of a a . The second line of the test case contains n n integers a1,a2,,an a_1, a_2, \dots, a_n ( 1ai100 1 \le a_i \le 100 ), where ai a_i is the i i -th element of a a .

输出格式

For each test case, print the answer: "YES" if it is possible to obtain the array consisting of only one element using several (possibly, zero) moves described in the problem statement, or "NO" otherwise.

样例 #1

样例输入 #1

5
3
1 2 2
4
5 5 5 5
3
1 2 4
4
1 3 4 4
1
100

样例输出 #1

YES
YES
NO
NO
YES

提示

In the first test case of the example, we can perform the following sequence of moves:

  • choose i=1 i=1 and j=3 j=3 and remove ai a_i (so a a becomes [2;2] [2; 2] );
  • choose i=1 i=1 and j=2 j=2 and remove aj a_j (so a a becomes [2] [2] ).

In the second test case of the example, we can choose any possible i i and j j any move and it doesn't matter which element we remove.

In the third test case of the example, there is no way to get rid of 2 2 and 4 4 .