问题 L: Equalize the Array

内存限制:512 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:3 通过:3

题目描述

You are given an array a consisting of n integers.

In one move, you can choose a positive integer x, such that x is one of the modes of the array, then add 11 to each x in a.

An integer x is a mode of an array a if and only if x appears most frequently in a. Note that an array may have multiple modes (e.g. 2,32,3 are both the modes of [2,2,1,3,3][2,2,1,3,3]).

Find out if it is possible to get an array that all elements in it are equal through several (possibly zero) such moves.

输入格式

The first line contains a single integer T (1≤�≤1001T100), denoting the number of test cases.

For each test case, the first line contains an integer n (1≤�≤5⋅1051n5105).

The next line contains n integers. The i-th number denotes ��ai (1≤��≤�1ain).

It is guaranteed that the sum of n over all test cases does not exceed 106106.

输出格式

For each test case, output a string. If it is possible, output YES; otherwise, output NO.

输入样例 复制

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

输出样例 复制

YES
NO
YES