#C8334. Split List into Two Equal Sum Contiguous Parts

    ID: 52305 Type: Default 1000ms 256MiB

Split List into Two Equal Sum Contiguous Parts

Split List into Two Equal Sum Contiguous Parts

Given a list of integers, determine if it is possible to split the list into exactly two non-empty contiguous sub-lists such that their sums are equal. Formally, given a list (a) of (n) integers, find if there exists an index (i) with (1 \le i < n) satisfying [ \sum_{j=0}^{i-1} a_j = \sum_{j=i}^{n-1} a_j ] If such an index exists, output YES; otherwise, output NO.

inputFormat

The input is given via standard input. The first line contains an integer (n) (with (2 \le n \le 10^5)) representing the number of elements. The second line contains (n) space-separated integers, where each integer represents the value in the list.

outputFormat

Output a single line via standard output containing either YES if the list can be split into two non-empty contiguous parts with equal sums, or NO otherwise.## sample

6
1 2 3 3 2 1
YES

</p>