#K54522. Find the Unique Element in an Array

    ID: 29772 Type: Default 1000ms 256MiB

Find the Unique Element in an Array

Find the Unique Element in an Array

You are given an array of n integers where every element appears exactly twice except for one element that appears only once. Your task is to determine this unique element.

This can be efficiently achieved using the XOR operation. Recall that for any integer a, the property \(a \oplus a = 0\) holds, and \(0 \oplus a = a\). Thus, by XOR-ing all the numbers in the array, the duplicate numbers cancel out and only the unique number remains.

Note: The input will be provided via standard input (stdin) and the output via standard output (stdout).

inputFormat

The first line contains an integer n — the number of elements in the array.

The second line contains n space-separated integers.

outputFormat

Output a single integer, which is the element that appears only once in the array.

## sample
5
4 1 2 1 2
4