#K41807. Find the Single Occurrence

    ID: 26947 Type: Default 1000ms 256MiB

Find the Single Occurrence

Find the Single Occurrence

You are given an array of integers in which every element appears exactly twice except for one element that appears only once. Your task is to find this unique number.

The solution uses the properties of the bitwise XOR operator. Recall that for any two numbers, the XOR operation satisfies:

$$a \oplus a = 0$$ and $$a \oplus 0 = a$$

Using these properties, if you XOR all numbers in the array, the result will be the unique number that only appears once.

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

inputFormat

The input is read from stdin and 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 integers separated by spaces representing the elements of the array.

It is guaranteed that all numbers except one appear exactly twice.

outputFormat

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

## sample
1
1
1