Back

Benford's Law

Worth 4 point(s) - Runtime Limit: 1 seconds

Introduction

Benford’s law, also called the first digit-law, is pretty neat. Benford’s law states that the leading digits of a set of data that has large range tend to be biased toward lower digits. For example, in a set of data with a lowest value of 14 and a largest value of 24544, around 30% of the numbers would be expected to start with a 1 while less that 5% would be expected to start with a 9.
The full probability table is shown below.

Benford’s law is commonly used by accounting firms to catch fraud. Bank account data that has been tampered usually doesn’t follow Benford’s law. Your job is to write a program that analyzes data to determine if it follows Benford’s law. Specifically, determine if 1 is the leading digit in at least five times as many entries as 9.

Input:
The first line of input contains an integer T, denoting the number of test cases. Each test case begins with an integer N, denoting the number of entries in the test case. The following line contains the N entries of the test case separated by spaces. Each entry is a non-negative integer.

Output:
For each test case, print a line containing “YES” if the data follows the specification above or “NO” if it doesn’t.

Sample Input

3
5
123 1254 95562 943223 994
10
12 96 14 83 14 324 453 12 12 45
7
232 26 26 134 27 22 29

Sample Output

NO
YES
YES