#C13160. Find the Unique Element

    ID: 42668 Type: Default 1000ms 256MiB

Find the Unique Element

Find the Unique Element

You are given an array of integers in which every element appears exactly three times except for one element which appears only once. Your task is to find and output this unique element.

The solution should run in linear time and use constant extra space. The efficient approach involves using bitwise operations to count bits across all numbers and isolate the unique element.

In mathematical terms, if the input array is \( A = [a_1, a_2, ..., a_n] \) where for all \( a_i \) (except one unique number \( u \)) it holds that \( \text{count}(a_i) = 3 \), then find \( u \) such that:

[ \text{For all } a \neq u, \quad \text{count}(a) = 3 \quad \text{and} \quad \text{count}(u) = 1. ]

inputFormat

The input is read from standard input. The first line contains a single integer \( n \) denoting the number of elements in the array. The second line contains \( n \) space-separated integers, which are the elements of the array.

outputFormat

Output the unique integer that appears only once in the array. The answer should be printed to standard output.

## sample
4
2 2 3 2
3