#K51217. Find the Unique Number

    ID: 29039 Type: Default 1000ms 256MiB

Find the Unique Number

Find the Unique Number

Given an array of non-negative integers where every element appears exactly twice except for one unique element which appears only once, your task is to find and output the unique number.

It is guaranteed that the array contains exactly one such unique number.

Hint: You may use the XOR operation which satisfies the properties $$a \oplus a = 0$$ and $$a \oplus 0 = a$$ to solve the problem in O(n) time and O(1) space.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (n) representing the number of elements in the array. The second line contains (n) space-separated non-negative integers.

outputFormat

Print a single integer to standard output (stdout) — the unique number in the array.## sample

7
2 2 3 4 4 5 5
3