#P1566. Count Add Equations
Count Add Equations
Count Add Equations
Given an integer set, we define an add equation as follows: an element in the set can be represented as the sum of one or more of the other elements in the set. For example, for the set ({1,2,3}), the equation (3 = 1+2) is an add equation. Note that (3 = 1+2) and (3 = 2+1) are considered the same add equation.
Formally, given a set (S) of integers, count the number of elements (a \in S) for which there exists a non-empty subset (T \subseteq S \setminus {a}) such that (\sum_{x \in T} x = a).
inputFormat
The first line contains an integer (n) representing the number of elements in the set. The second line contains (n) space-separated integers.
outputFormat
Output a single integer representing the number of add equations in the set.
sample
3
1 2 3
1