#C7165. Sum of Unique Elements
Sum of Unique Elements
Sum of Unique Elements
You are given an array of integers. Your task is to compute the sum of all elements that occur exactly once in the array.
Formally, let \( A \) be the array and let \( U = \{ x \in A \mid frequency(x)=1 \} \). You need to compute the sum defined as:
\( S = \sum_{x \in U} x \).
If there are no unique elements, the result should be 0.
The input is read from standard input and the answer should be printed to standard output.
inputFormat
The first line of input contains an integer ( n ), representing the number of elements in the array. The second line contains ( n ) space-separated integers denoting the elements of the array.
outputFormat
Print a single integer — the sum of all unique (non-repeating) elements in the array.## sample
7
1 2 2 3 4 4 5
9