#K40747. Happy Subsequences

    ID: 26711 Type: Default 1000ms 256MiB

Happy Subsequences

Happy Subsequences

You are given several test cases. In each test case, you are given an array of positive integers. Your task is to determine whether it is possible to choose a non-empty subsequence (not necessarily contiguous) that is happy.

A subsequence is defined as happy if there exist two indices \( i \) and \( j \) with \( i < j \) such that the element at index \( j \) is divisible by the element at index \( i \), i.e., \[ a_j \bmod a_i = 0 \]

If such a pair exists in the given array, output YES; otherwise, output NO.

inputFormat

The input is read from standard input and has the following format:

  • The first line contains a single integer \( T \) denoting the number of test cases.
  • For each test case, the first line contains a single integer \( n \) representing the number of elements in the array.
  • The second line contains \( n \) space-separated integers \( a_1, a_2, \dots, a_n \), representing the array.

outputFormat

For each test case, print a single line containing YES if there exists a happy subsequence then YES, otherwise print NO.

## sample
3
3
2 4 6
4
3 6 7 12
5
5 7 11 13 17
YES

YES NO

</p>