#C1517. Unique Element Finder

    ID: 44731 Type: Default 1000ms 256MiB

Unique Element Finder

Unique Element Finder

You are given an array of integers where every element appears exactly twice except for one element that appears only once. Your task is to find this unique element using an efficient algorithm leveraging the bitwise XOR operation. The XOR operator is denoted by \(\oplus\) and has the useful property that \(a \oplus a = 0\) and \(a \oplus 0 = a\), which makes it possible to cancel out the duplicate elements.

Given the array \(A = [a_1, a_2, \dots, a_n]\), all elements except one occur twice. Compute the unique element using the following formula:

[ \text{unique} = a_1 \oplus a_2 \oplus \dots \oplus a_n ]

Read the input from standard input and output the result to standard output.

inputFormat

The input is given via standard input (stdin). The first line contains a single integer \(n\) denoting the number of elements in the array. The second line contains \(n\) space-separated integers representing the array \(A\).

outputFormat

Output the unique element (the element that appears exactly once) to standard output (stdout).

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