CF2242A Bigrams

Description

A bigram in a string is a pair of adjacent characters. For example, the string helloello contains $ 8 $ bigrams: he, el, ll, lo, oe, el, ll, lo. Monocarp has cards with letters: $ c_1 $ cards with the letter a, $ c_2 $ cards with the letter b, ..., $ c_k $ cards with the $ k $ -th letter of the Latin alphabet. He wants to make a string from these cards, using each card exactly once. The resulting string must contain at least two equal bigrams. The order of characters in each bigram matters; for example, the string aba does not have two equal bigrams. Determine whether it is possible to make a string that satisfies these requirements.

Input Format

The first line contains one integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases. Each test case consists of two lines: - the first line contains one integer $ k $ ( $ 1 \le k \le 10 $ ); - the second line contains $ k $ integers $ c_1, c_2, \dots, c_k $ ( $ 1 \le c_i \le 10^8 $ ), where $ c_i $ is the number of cards with the $ i $ -th letter of the Latin alphabet.

Output Format

For each test case, output YES if it is possible to construct a string satisfying the condition, or NO otherwise. Each letter can be output in any case. For example, yes, Yes, yEs will be recognized as a positive answer.

Explanation/Hint

In the first example, you can only make the string a, which contains no bigrams. In the second example, you can make the string aaa, which contains two bigrams aa. In the third example, you can make the string aaaa, which contains three bigrams aa. In the fourth example, you can make the string aab, aba, or baa. None of these strings contains two equal bigrams. In the fifth example, you can make the string aabab, which contains two bigrams ab.