#C4051. Find the Unique Element
Find the Unique Element
Find the Unique Element
You are given an array of integers where every element appears exactly three times except for one element which appears exactly once. Your task is to find this unique element.
The solution must read input from stdin
and print the result to stdout
. The input begins with an integer n representing the number of elements in the array. The next line contains n space-separated integers.
Mathematically, if the array is \(a_1, a_2, \dots, a_n\), then every number except one follows the condition:
\[ \text{count}(x) = 3 \quad \text{for all } x \neq k \]
The unique element \(k\) appears only once.
inputFormat
The first line contains a single integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers.
outputFormat
Print the unique element that appears only once.
## sample4
2 2 3 2
3