#C3345. Prime Subarray Sum
Prime Subarray Sum
Prime Subarray Sum
Derek loves puzzles involving prime numbers. In this problem, you are given an array of integers. Your task is to determine whether there exists any contiguous subarray whose sum is a prime number. A prime number is a number \(p\) greater than 1 that has no positive divisors other than 1 and \(p\) itself.
If such a subarray exists, output YES
; otherwise, output NO
.
Note: The array can contain negative numbers. The subarray must be contiguous.
inputFormat
The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers representing the elements of the array. If \(n = 0\), the array is empty.
outputFormat
Output a single line with YES
if there exists at least one contiguous subarray whose sum is a prime number, otherwise output NO
.
5
2 3 -5 5 6
YES