运用鸽巢原理,假设最多的糖果有Max个,那么必须要有max-1个其他种类的糖果才能吃完,如果其他种类的糖果多于max-1个,那么至少要有一个种糖果存在max+1个,才会出现当前状态无解,而这种状况下又与最多糖果数为max矛盾,所以要满足有解的充要条件是max-1 <= sum - max

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>

using namespace std;


int main ( )
{
    int t,n;
    long long maxn , x , sum;
    scanf ( "%d" , &t );
    while ( t-- )
    {
        maxn =0;
        sum = 0;
        scanf ( "%d" , &n );
        while ( n -- )
        {
            scanf ( "%lld" , &x );
            maxn = max ( maxn , x );
            sum += x;
        }
        if ( sum - maxn + 1  >= maxn ) puts ( "Yes");
        else puts ( "No" );
    }
}