#C3265. Find the Single Number

    ID: 46673 Type: Default 1000ms 256MiB

Find the Single Number

Find the Single Number

You are given a list 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.

One efficient method to solve this problem is to use the bitwise XOR operation. Recall that for any integer (a), the properties (a \oplus a = 0) and (a \oplus 0 = a) hold. Therefore, the XOR of all numbers in the list will cancel out the numbers appearing twice and leave the unique number.

inputFormat

The input is given via standard input (stdin). The first line contains an integer (n) that represents the number of elements in the list. The second line contains (n) space-separated integers.

outputFormat

Output the single number that appears only once in the list to standard output (stdout).## sample

3
2 2 1
1