#K84837. Find the Unique Element

    ID: 36508 Type: Default 1000ms 256MiB

Find the Unique Element

Find the Unique Element

You are given an array of integers containing exactly one element that does not appear twice. All the other elements appear exactly twice. Your task is to find and output the unique element.

This problem can be solved efficiently using the bitwise XOR operation, which has the property that a ⊕ a = 0 and a ⊕ 0 = a. Thus, when performing XOR over all the elements, duplicate elements cancel out, leaving the unique element.

Example: For the input array [4, 1, 2, 1, 2, 4, 3], the output is 3.

inputFormat

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

The second line contains n space-separated integers representing the array elements.

You can assume that n is odd and exactly one element appears once.

outputFormat

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

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