Tom The Equaliser

0

0 votes
Problem

Tom has lots of skyscrapers in his LEGO city, some buildings are very tall while some are too short. Tom doesn't like that, he wants equality for all buildings as it becomes difficult to maintain the really tall ones and the short ones are easily ignored.

Tom is too lazy to work and has given you the job, the chief architect of the city!

The buildings are placed in a straight line, side-by-side. You have to level all the buildings by removing 1 block at a time from the top of a taller building and placing them on any adjacent shorter building.

Tom wants to know if it is possible to achieve total equality, that is, all buildings of the same height.

Input

  • 1st line contains an integer T denoting the number of test cases.
  • 1st line of each test case contains an integer N denoting the number of buildings in Tom's LEGO city.
  • 2nd line of each test case contains a sequence of N space-separated integers, A1, A2, A3...AN the heights of the buildings.

Output

For each test case, print a single line which is either "Yes" (Without Quotes) or "No" (Without Quotes).

Constraints

1 <= T <= 10
1 <= N <= \(10^5\)
0 <= Ai <= \(10^9\)

Sample Input
1
5
6 2 3 5 4
Sample Output
Yes
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?