#C1764. Unique Element Finder

    ID: 45005 Type: Default 1000ms 256MiB

Unique Element Finder

Unique Element Finder

Given an array of integers where every element appears exactly three times except for one element that appears exactly once, your task is to find and output that unique element. The array may include positive numbers, negative numbers, and zero.

Note: Aim for an algorithm with linear runtime complexity, i.e. \(O(n)\), and constant extra space, i.e. \(O(1)\).

This can be formulated as: Given an array \(A\), find the unique integer \(x\) such that every other element in \(A\) appears exactly three times.

inputFormat

The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers, which are the elements of the array.

outputFormat

Output a single integer which is the element that appears exactly once.

## sample
4
3 3 3 1
1

</p>