#K45732. Subarray Sum Exists

    ID: 27819 Type: Default 1000ms 256MiB

Subarray Sum Exists

Subarray Sum Exists

Given an array of n integers and a target sum \( T \), determine if there exists a non-empty contiguous subarray whose sum is exactly \( T \). More formally, you are given an array \( a_1, a_2, \dots, a_n \) and you need to decide if there exists indices \( 1 \le l \le r \le n \) such that

\[ \sum_{i=l}^{r} a_i = T \]

If such a subarray exists, print "Yes", otherwise print "No".

inputFormat

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

  1. The first line contains a single integer n — the number of elements in the array.
  2. The second line contains n integers separated by spaces — the elements of the array.
  3. The third line contains a single integer T — the target sum.

outputFormat

Output a single line to standard output containing either "Yes" if there exists a contiguous subarray with sum exactly equal to T, or "No" otherwise.

## sample
5
1 2 3 4 5
9
Yes