#K64777. Find the Unique Element

    ID: 32051 Type: Default 1000ms 256MiB

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 only once. Your task is to find that unique element.

More formally, given an array \( nums \) of length \( n \), where every element appears exactly three times except for one, you need to output the element that appears only once.

The solution should work in linear time complexity \( O(n) \) and without using extra memory for a hash table.

inputFormat

The input is given via standard input (stdin) and consists of two lines:

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

outputFormat

Output a single integer to standard output (stdout) which is the unique element appearing exactly once.

## sample
7
2 2 3 2 4 4 4
3