#B4038. Balanced Sequence
Balanced Sequence
Balanced Sequence
You are given a sequence of n positive integers \(a_1, a_2, \dots, a_n\). A sequence is said to be balanced if and only if there exists an index \(i\) (\(1 \le i < n\)) such that
[ \sum_{j=1}^{i} a_j = \sum_{j=i+1}^{n} a_j ]
Your task is to determine whether the given sequence is balanced or not.
inputFormat
The first line contains an integer n
(the number of elements in the sequence). The second line contains n
positive integers separated by spaces representing the sequence \(a_1, a_2, \dots, a_n\).
outputFormat
Output a single line containing YES
if the sequence is balanced, otherwise output NO
.
sample
2
1 1
YES