#K84967. Find the Unique Element

    ID: 36537 Type: Default 1000ms 256MiB

Find the Unique Element

Find the Unique Element

Given an integer array where every element occurs exactly three times, except for one element that occurs only once, your task is to identify and output that unique element.

The problem can be formulated as follows:

( \text{For an array } A, \text{ if } \forall x \in A \setminus {y}, \text{ frequency}(x)=3 \text{ and } \text{frequency}(y)=1, \text{ then find } y. )

For example, if the input array is [2, 2, 3, 2], the output should be 3.

inputFormat

The first line contains an integer ( n ) representing the number of elements in the array. The second line contains ( n ) space-separated integers that form the array.

outputFormat

Output a single integer which is the unique element that appears only once in the array.## sample

4
2 2 3 2
3