| antontrygubO_o UOI problems |
|---|
| Закончено |
You are given an array of integers $$$a$$$ of length $$$n$$$.
Determine whether there exists a permutation of its elements $$$b$$$ such that for every $$$2\leq i \leq n-1$$$, the condition $$$b_{i-1} + b_{i+1} \ge 2\cdot b_i$$$ holds.
In this problem, each test contains several sets of input data. You need to solve the problem independently for each such set.
The first line contains a single integer $$$T$$$ $$$(1\le T\le 10^5)$$$ — the number of sets of input data. The description of the input data sets follows.
In the first line of each input data set, there is a single integer $$$n$$$ $$$(3\le n\le 3\cdot 10^5)$$$ — the length of the array $$$a$$$.
In the second line of each input data set, there are $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(0\le a_i\le 10^9)$$$ — the elements of the array $$$a$$$.
It is guaranteed that the sum of $$$n$$$ across all input data sets of a single test does not exceed $$$3\cdot 10^5$$$.
For each set of input data, output on a separate line "YES", if the desired permutation exists, and "NO" otherwise.
Let $$$S$$$ be the sum $$$n$$$ over all input data sets of one test.
1040 3 4 645 4 1 481 4 4 8 6 10 10 472 1 5 1 9 4 667 1 6 10 2 376 6 10 2 5 3 849 9 1 548 4 3 471 2 1 6 4 2 973 9 7 5 9 10 10
YES NO NO YES YES NO YES YES YES NO
In the first set of input data from the first example, the permutations of the array $$$[0, 3, 4, 6]$$$ that satisfy the described condition are $$$[4, 0, 3, 6]$$$ and $$$[6, 3, 0, 4]$$$.
| Название |
|---|


