#K80152. Find the Unique Element

    ID: 35467 Type: Default 1000ms 256MiB

Find the Unique Element

Find the Unique Element

Given an array of n integers, where every element appears exactly twice except for one that appears only once, your task is to find that unique element using bitwise operations.

The solution should efficiently identify the unique element by using the XOR operation. Recall that for any integer a, a ⊕ a = 0 and a ⊕ 0 = a. Thus, when you XOR all the numbers in the array, the pairs cancel out, leaving only the unique element.

Mathematical Formulation: Let the array be \(a_1, a_2, \ldots, a_n\). Then the result is:

\(result = a_1 \oplus a_2 \oplus \cdots \oplus a_n\)

Use this property to design a solution that reads the input from standard input and prints the answer to standard output.

inputFormat

The input consists of two lines:

  • 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

Output a single integer — the unique element that appears only once in the array.

## sample
1
1
1