#C9795. Prime Subset Sum Existence

    ID: 53927 Type: Default 1000ms 256MiB

Prime Subset Sum Existence

Prime Subset Sum Existence

You are given an array of N integers. Your task is to determine if there exists a non-empty subset of the array such that the sum of its elements is a prime number.

In mathematical terms, for a given set \( S \), you need to decide whether there exists a non-empty subset \( T \subseteq S \) such that \[ \sum_{x \in T} x \] is a prime number.

For instance, if the array is [1, 2, 3, 4, 5], the subset [2, 3] sums to 5, which is prime, so the answer would be YES. Otherwise, if no such subset exists, the answer should be NO.

inputFormat

The input consists of two lines:

  • The first line contains an integer N (1 ≤ N ≤ 20), representing the number of elements in the array.
  • The second line contains N space-separated integers.

outputFormat

Output a single line containing YES if there exists any non-empty subset whose sum is a prime number, otherwise output NO.

## sample
5
1 2 3 4 5
YES

</p>