#K56542. Find the Single Number

    ID: 30221 Type: Default 1000ms 256MiB

Find the Single Number

Find the Single Number

You are given an array of integers where every element appears exactly twice except for one unique element that appears only once. Your task is to find that single element using a linear-time algorithm and constant extra space.

Note: You should read the input from standard input (stdin) and write the output to standard output (stdout).

The algorithm hint: Use the XOR operator, since a XOR a = 0 and a XOR 0 = a, which helps in canceling out pairs.

For example:

Input:
5
4 1 2 1 2

Output: 4

</p>

inputFormat

The first line contains an integer n representing the number of elements in the array. The second line contains n space-separated integers.

For example:

5
4 1 2 1 2

outputFormat

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

For example:

4
## sample
5
4 1 2 1 2
4