#C6510. Equal Sum Split

    ID: 50279 Type: Default 1000ms 256MiB

Equal Sum Split

Equal Sum Split

You are given an array of integers. Your task is to determine whether it is possible to split the array into two non-empty parts such that the sum of the elements in the left part is equal to the sum of the elements in the right part.

Note: The split must occur between two indices, meaning that both parts must contain at least one element. Formally, given an array \(A\) of length \(n\), find an index \(i\) (with \(1 \le i \lt n\)) such that:

[ \sum_{j=0}^{i-1} A[j] = \sum_{j=i}^{n-1} A[j] ]

If such an index exists, print YES; otherwise, print NO.

inputFormat

The input is given via standard input and consists of two lines:

The first line contains a single integer (n) (the number of elements in the array).

The second line contains (n) space-separated integers representing the elements of the array.

outputFormat

Output a single line to standard output containing either YES or NO depending on whether it is possible to split the list into two non-empty parts with equal sums.## sample

5
1 2 3 4 5
NO