只有下面两种情况满足条件:
1. 只有一个数字
2. 只有两个数字且两个数字不相邻
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include "bits/stdc++.h"
using namespace std;
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fios ofstream("test.txt");cout.rdbuf(out.rdbuf())
#define endl "\n"
#define INF 0x3f3f3f3f
#define MINF 2147483647
#define eps 1e-6
#define PI acos(-1)
#define lowbit(x) (x & (-x))
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 100010;
int n;
int main()
{
int T;
cin >> T;
while(T--)
{
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
if(a.size() == 1) cout << "YES" << endl;
else if(a.size() == 2 && abs(a[0] - a[1]) != 1) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}